catalog-client: fix queryEntities not handling errors properly
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -525,6 +525,18 @@ describe('CatalogClient', () => {
|
||||
'?cursor=prevcursor',
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle errors', async () => {
|
||||
const mockedEndpoint = jest
|
||||
.fn()
|
||||
.mockImplementation((_req, res, ctx) => res(ctx.status(401)));
|
||||
|
||||
server.use(rest.get(`${mockBaseUrl}/entities/by-query`, mockedEndpoint));
|
||||
|
||||
await expect(() => client.queryEntities()).rejects.toThrow(
|
||||
/Request failed with 401 Unauthorized/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getEntityByRef', () => {
|
||||
|
||||
@@ -237,9 +237,9 @@ export class CatalogClient implements CatalogApi {
|
||||
}
|
||||
}
|
||||
|
||||
return this.apiClient
|
||||
.getEntitiesByQuery({ query: params }, options)
|
||||
.then(r => r.json());
|
||||
return this.requestRequired(
|
||||
await this.apiClient.getEntitiesByQuery({ query: params }, options),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user