mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +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();
|
jest.clearAllMocks();
|
||||||
return global.renovateCache.rmAll();
|
return global.renovateCache.rmAll();
|
||||||
});
|
});
|
||||||
it('returns null for empty result', async () => {
|
it('throws for empty result', async () => {
|
||||||
got.mockResolvedValueOnce(null);
|
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 () => {
|
it('returns null for missing fields', async () => {
|
||||||
got.mockResolvedValueOnce({});
|
got.mockResolvedValueOnce({});
|
||||||
|
@ -77,7 +79,9 @@ describe('datasource/cdnjs', () => {
|
||||||
got.mockImplementationOnce(() => {
|
got.mockImplementationOnce(() => {
|
||||||
throw new Error();
|
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 () => {
|
it('returns null with wrong auth token', async () => {
|
||||||
got.mockRejectedValueOnce({ statusCode: 401 });
|
got.mockRejectedValueOnce({ statusCode: 401 });
|
||||||
|
|
|
@ -101,13 +101,13 @@ export async function getPkgReleases({
|
||||||
) {
|
) {
|
||||||
throw new DatasourceError(err);
|
throw new DatasourceError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.statusCode === 401) {
|
if (err.statusCode === 401) {
|
||||||
logger.debug(errorData, 'Authorization error');
|
logger.debug(errorData, 'Authorization error');
|
||||||
} else if (err.statusCode === 404) {
|
} else if (err.statusCode === 404) {
|
||||||
logger.debug(errorData, 'Package lookup error');
|
logger.debug(errorData, 'Package lookup error');
|
||||||
} else {
|
} 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