renovate/test/workers/repository/error.spec.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

import handleError from '../../../lib/workers/repository/error';
jest.mock('../../../lib/workers/repository/error-config');
let config;
beforeEach(() => {
jest.resetAllMocks();
config = require('../../config/config/_fixtures');
});
describe('workers/repository/error', () => {
describe('handleError()', () => {
const errors = [
'uninitiated',
'empty',
'disabled',
'repository-changed',
'fork',
'no-package-files',
'config-validation',
'registry-failure',
'archived',
'mirror',
'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',
2019-02-13 21:33:58 +00:00
'bad-credentials',
'rate-limit-exceeded',
'lockfile-error',
2018-09-08 05:16:05 +00:00
'disk-space',
'platform-failure',
2018-07-29 13:50:19 +00:00
'no-vulnerability-alerts',
'cannot-fork',
'integration-unauthorized',
'authentication-error',
'temporary-error',
];
errors.forEach(err => {
it(`errors ${err}`, async () => {
const res = await handleError(config, new Error(err));
expect(res).toEqual(err);
});
});
2019-06-12 14:14:44 +00:00
it('rewrites git 5xx error', async () => {
const gitError = new Error(
"fatal: unable to access 'https://**redacted**@gitlab.com/learnox/learnox.git/': The requested URL returned error: 500\n"
);
const res = await handleError(config, gitError);
expect(res).toEqual('platform-failure');
});
2019-06-12 14:14:44 +00:00
it('rewrites git remote error', async () => {
const gitError = new Error(
'fatal: remote error: access denied or repository not exported: /b/nw/bd/27/47/159945428/108610112.git\n'
);
const res = await handleError(config, gitError);
expect(res).toEqual('platform-failure');
});
it('handles unknown error', async () => {
const res = await handleError(config, new Error('abcdefg'));
expect(res).toEqual('unknown-error');
});
});
});