Merge pull request #12492 from dehamzah/register-dryrun-error-code

Fix Error Code in Register Component DryRun
This commit is contained in:
Ben Lambert
2022-07-12 09:20:02 +02:00
committed by GitHub
3 changed files with 27 additions and 3 deletions
@@ -202,7 +202,7 @@ describe('DefaultLocationServiceTest', () => {
{ type: 'url', target: 'https://backstage.io/catalog-info.yaml' },
true,
),
).rejects.toThrowError('Duplicate nested entity: location:default/foo');
).rejects.toThrow('Duplicate nested entity: location:default/foo');
});
it('should return exists false when the location does not exist beforehand', async () => {
@@ -270,6 +270,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', () => {
@@ -79,7 +79,7 @@ export class DefaultLocationService implements LocationService {
stringifyEntityRef(processed.completedEntity),
)
) {
throw new Error(
throw new InputError(
`Duplicate nested entity: ${stringifyEntityRef(
processed.completedEntity,
)}`,
@@ -88,7 +88,7 @@ export class DefaultLocationService implements LocationService {
unprocessedEntities.push(...processed.deferredEntities);
entities.push(processed.completedEntity);
} else {
throw Error(processed.errors.map(String).join(', '));
throw new InputError(processed.errors.map(String).join(', '));
}
}
return entities;