renovate/test/workers/repository/error.spec.js
Rhys Arkins e306f707db fix: abort renovation if repository has changed during run
If attempting to create a branch and it already exists, or attempting to update a branch and it no longer exists, then we abort.
2018-02-03 15:45:43 +01:00

37 lines
939 B
JavaScript

const { handleError } = require('../../../lib/workers/repository/error');
jest.mock('../../../lib/workers/repository/error-config');
let config;
beforeEach(() => {
jest.resetAllMocks();
config = require('../../_fixtures/config');
});
describe('workers/repository/error', () => {
describe('handleError()', () => {
const errors = [
'uninitiated',
'disabled',
'repository-changed',
'fork',
'no-package-files',
'loops>5',
'config-validation',
'registry-failure',
'archived',
'blocked',
'not-found',
];
errors.forEach(err => {
it(`errors ${err}`, async () => {
const res = await handleError(config, new Error(err));
expect(res).toEqual(err);
});
});
it('handles unknown error', async () => {
const res = await handleError(config, new Error('abcdefg'));
expect(res).toEqual('unknown-error');
});
});
});