catalog-client: fix queryEntities not handling errors properly

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2024-11-20 22:05:21 +01:00
parent 7d8777dbba
commit cc4c2baf97
2 changed files with 15 additions and 3 deletions
@@ -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', () => {
+3 -3
View File
@@ -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),
);
}
/**