diff --git a/plugins/catalog-backend/src/next/DefaultLocationService.test.ts b/plugins/catalog-backend/src/next/DefaultLocationService.test.ts index 662be5d3a6..bf2bee147a 100644 --- a/plugins/catalog-backend/src/next/DefaultLocationService.test.ts +++ b/plugins/catalog-backend/src/next/DefaultLocationService.test.ts @@ -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(); }); }); diff --git a/plugins/catalog-backend/src/next/DefaultLocationService.ts b/plugins/catalog-backend/src/next/DefaultLocationService.ts index 884410c2f0..460ba61ec8 100644 --- a/plugins/catalog-backend/src/next/DefaultLocationService.ts +++ b/plugins/catalog-backend/src/next/DefaultLocationService.ts @@ -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 { - return this.store.listLocations(); + async listLocations(): Promise { + const locations = await this.store.listLocations(); + return locations.map(location => ({ data: location })); } + getLocation(id: string): Promise { return this.store.getLocation(id); } diff --git a/plugins/catalog-backend/src/next/types.ts b/plugins/catalog-backend/src/next/types.ts index fbc243ce69..05fd75522a 100644 --- a/plugins/catalog-backend/src/next/types.ts +++ b/plugins/catalog-backend/src/next/types.ts @@ -27,11 +27,15 @@ export interface LocationService { spec: LocationSpec, dryRun: boolean, ): Promise<{ location: Location; entities: Entity[] }>; - listLocations(): Promise; + listLocations(): Promise; getLocation(id: string): Promise; deleteLocation(id: string): Promise; } +export type LocationResponse = { + data: Location; +}; + export interface LocationStore { createLocation(spec: LocationSpec): Promise; listLocations(): Promise;