2017-11-05 04:45:49 +00:00
|
|
|
const { handleError } = require('../../../lib/workers/repository/error');
|
|
|
|
|
2017-12-18 08:39:52 +00:00
|
|
|
jest.mock('../../../lib/workers/repository/error-config');
|
|
|
|
|
2017-11-05 04:45:49 +00:00
|
|
|
let config;
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetAllMocks();
|
|
|
|
config = require('../../_fixtures/config');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('workers/repository/error', () => {
|
|
|
|
describe('handleError()', () => {
|
|
|
|
const errors = [
|
|
|
|
'uninitiated',
|
2018-09-25 06:50:47 +00:00
|
|
|
'empty',
|
2017-11-05 04:45:49 +00:00
|
|
|
'disabled',
|
2018-02-03 14:45:43 +00:00
|
|
|
'repository-changed',
|
2017-11-05 04:45:49 +00:00
|
|
|
'fork',
|
|
|
|
'no-package-files',
|
2017-12-18 08:39:52 +00:00
|
|
|
'config-validation',
|
2018-01-14 17:58:49 +00:00
|
|
|
'registry-failure',
|
2017-12-31 19:28:22 +00:00
|
|
|
'archived',
|
2018-02-08 15:04:25 +00:00
|
|
|
'renamed',
|
2018-02-02 17:04:41 +00:00
|
|
|
'blocked',
|
2017-12-31 19:47:46 +00:00
|
|
|
'not-found',
|
2018-02-05 21:23:50 +00:00
|
|
|
'forbidden',
|
2018-03-22 08:26:20 +00:00
|
|
|
'rate-limit-exceeded',
|
2018-05-24 14:28:36 +00:00
|
|
|
'lockfile-error',
|
2018-09-08 05:16:05 +00:00
|
|
|
'disk-space',
|
2018-07-21 06:38:13 +00:00
|
|
|
'platform-failure',
|
2018-07-29 13:50:19 +00:00
|
|
|
'no-vulnerability-alerts',
|
2018-10-08 08:41:55 +00:00
|
|
|
'cannot-fork',
|
2018-12-03 11:03:46 +00:00
|
|
|
'integration-unauthorized',
|
2017-11-05 04:45:49 +00:00
|
|
|
];
|
|
|
|
errors.forEach(err => {
|
2017-12-18 08:39:52 +00:00
|
|
|
it(`errors ${err}`, async () => {
|
|
|
|
const res = await handleError(config, new Error(err));
|
2017-11-05 04:45:49 +00:00
|
|
|
expect(res).toEqual(err);
|
|
|
|
});
|
|
|
|
});
|
2017-12-18 08:39:52 +00:00
|
|
|
it('handles unknown error', async () => {
|
|
|
|
const res = await handleError(config, new Error('abcdefg'));
|
2017-11-05 04:45:49 +00:00
|
|
|
expect(res).toEqual('unknown-error');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|