mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(cdnjs): datasourceError on unknown error
This commit is contained in:
parent
cbee46d014
commit
93d475eeb4
2 changed files with 9 additions and 5 deletions
|
@ -45,9 +45,11 @@ describe('datasource/cdnjs', () => {
|
|||
jest.clearAllMocks();
|
||||
return global.renovateCache.rmAll();
|
||||
});
|
||||
it('returns null for empty result', async () => {
|
||||
it('throws for empty result', async () => {
|
||||
got.mockResolvedValueOnce(null);
|
||||
expect(await getPkgReleases({ lookupName: 'foo/bar' })).toBeNull();
|
||||
await expect(
|
||||
getPkgReleases({ lookupName: 'foo/bar' })
|
||||
).rejects.toThrowError(DATASOURCE_FAILURE);
|
||||
});
|
||||
it('returns null for missing fields', async () => {
|
||||
got.mockResolvedValueOnce({});
|
||||
|
@ -77,7 +79,9 @@ describe('datasource/cdnjs', () => {
|
|||
got.mockImplementationOnce(() => {
|
||||
throw new Error();
|
||||
});
|
||||
expect(await getPkgReleases({ lookupName: 'foo/bar' })).toBeNull();
|
||||
await expect(
|
||||
getPkgReleases({ lookupName: 'foo/bar' })
|
||||
).rejects.toThrowError(DATASOURCE_FAILURE);
|
||||
});
|
||||
it('returns null with wrong auth token', async () => {
|
||||
got.mockRejectedValueOnce({ statusCode: 401 });
|
||||
|
|
|
@ -101,13 +101,13 @@ export async function getPkgReleases({
|
|||
) {
|
||||
throw new DatasourceError(err);
|
||||
}
|
||||
|
||||
if (err.statusCode === 401) {
|
||||
logger.debug(errorData, 'Authorization error');
|
||||
} else if (err.statusCode === 404) {
|
||||
logger.debug(errorData, 'Package lookup error');
|
||||
} else {
|
||||
logger.warn(errorData, 'CDNJS lookup failure: Unknown error');
|
||||
logger.debug(errorData, 'CDNJS lookup failure: Unknown error');
|
||||
throw new DatasourceError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue