Merge pull request #12492 from dehamzah/register-dryrun-error-code
Fix Error Code in Register Component DryRun
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Fix Error Code in Register Component DryRun
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user