From eb91937a92502ee98dc0e06716d2ea04333642fb Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Mon, 11 Jul 2022 15:05:18 +0700 Subject: [PATCH] Add tests Signed-off-by: Dede Hamzah --- .../service/DefaultLocationService.test.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts index bd166cbd50..debf2e4b2f 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts @@ -197,7 +197,7 @@ describe('DefaultLocationServiceTest', () => { { type: 'url', target: 'https://backstage.io/catalog-info.yaml' }, true, ), - ).rejects.toThrowError('Duplicate nested entity: location:default/foo'); + ).rejects.toThrow(InputError); }); it('should return exists false when the location does not exist beforehand', async () => { @@ -264,6 +264,25 @@ describe('DefaultLocationServiceTest', () => { ), ).rejects.toThrow(InputError); }); + + it('should return default InputError for failed processed entities in dryRun mode', async () => { + store.listLocations.mockResolvedValueOnce([]); + + orchestrator.process.mockResolvedValueOnce({ + ok: false, + errors: [new Error('Error: Unable to read url')], + }); + + await expect( + locationService.createLocation( + { + type: 'url', + target: 'https://backstage.io/wrong-url/catalog-info.yaml', + }, + true, + ), + ).rejects.toThrow(InputError); + }); }); describe('listLocations', () => {