Make listLocations conform with current API
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -137,8 +137,23 @@ describe('DefaultLocationServiceTest', () => {
|
||||
});
|
||||
});
|
||||
describe('listLocations', () => {
|
||||
it('should call locationStore.deleteLocation', async () => {
|
||||
await locationService.listLocations();
|
||||
it('should call locationStore.listLocations', async () => {
|
||||
store.listLocations.mockResolvedValue([
|
||||
{
|
||||
id: '123',
|
||||
target: 'https://backstage.io/catalog-info.yaml',
|
||||
type: 'url',
|
||||
},
|
||||
]);
|
||||
await expect(locationService.listLocations()).resolves.toEqual([
|
||||
{
|
||||
data: {
|
||||
id: '123',
|
||||
target: 'https://backstage.io/catalog-info.yaml',
|
||||
type: 'url',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(store.listLocations).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
LocationService,
|
||||
LocationStore,
|
||||
CatalogProcessingOrchestrator,
|
||||
LocationResponse,
|
||||
} from './types';
|
||||
import { locationSpecToMetadataName } from './util';
|
||||
|
||||
@@ -87,9 +88,11 @@ export class DefaultLocationService implements LocationService {
|
||||
return { location, entities: [] };
|
||||
}
|
||||
|
||||
listLocations(): Promise<Location[]> {
|
||||
return this.store.listLocations();
|
||||
async listLocations(): Promise<LocationResponse[]> {
|
||||
const locations = await this.store.listLocations();
|
||||
return locations.map(location => ({ data: location }));
|
||||
}
|
||||
|
||||
getLocation(id: string): Promise<Location> {
|
||||
return this.store.getLocation(id);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,15 @@ export interface LocationService {
|
||||
spec: LocationSpec,
|
||||
dryRun: boolean,
|
||||
): Promise<{ location: Location; entities: Entity[] }>;
|
||||
listLocations(): Promise<Location[]>;
|
||||
listLocations(): Promise<LocationResponse[]>;
|
||||
getLocation(id: string): Promise<Location>;
|
||||
deleteLocation(id: string): Promise<void>;
|
||||
}
|
||||
|
||||
export type LocationResponse = {
|
||||
data: Location;
|
||||
};
|
||||
|
||||
export interface LocationStore {
|
||||
createLocation(spec: LocationSpec): Promise<Location>;
|
||||
listLocations(): Promise<Location[]>;
|
||||
|
||||
Reference in New Issue
Block a user