2020-03-05 20:57:24 +00:00
|
|
|
import * as massage from './massage';
|
2021-04-20 08:52:57 +00:00
|
|
|
import type { RenovateConfig } from './types';
|
2017-08-15 11:26:05 +00:00
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('config/massage', () => {
|
2017-08-15 11:26:05 +00:00
|
|
|
describe('massageConfig', () => {
|
|
|
|
it('returns empty', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {};
|
2017-08-15 11:26:05 +00:00
|
|
|
const res = massage.massageConfig(config);
|
2021-08-09 08:21:51 +00:00
|
|
|
expect(res).toEqual({});
|
2017-08-15 11:26:05 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2017-08-15 11:26:05 +00:00
|
|
|
it('massages strings to array', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2020-01-06 08:16:15 +00:00
|
|
|
schedule: 'before 5am' as never,
|
2017-08-15 11:26:05 +00:00
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
2021-10-27 05:24:36 +00:00
|
|
|
expect(Array.isArray(res.schedule)).toBeTrue();
|
2017-08-15 11:26:05 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2017-08-29 07:25:44 +00:00
|
|
|
it('massages npmToken', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2017-08-29 07:25:44 +00:00
|
|
|
npmToken: 'some-token',
|
|
|
|
};
|
2021-08-09 08:21:51 +00:00
|
|
|
expect(massage.massageConfig(config)).toEqual({
|
|
|
|
npmrc: '//registry.npmjs.org/:_authToken=some-token\n',
|
|
|
|
});
|
2017-08-29 07:25:44 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-01-29 10:43:42 +00:00
|
|
|
it('massages packageRules matchUpdateTypes', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2018-11-13 08:29:53 +00:00
|
|
|
packageRules: [
|
|
|
|
{
|
2021-01-29 10:43:42 +00:00
|
|
|
matchPackageNames: ['foo'],
|
2021-05-15 12:44:47 +00:00
|
|
|
separateMajorMinor: false,
|
2018-11-13 08:29:53 +00:00
|
|
|
minor: {
|
|
|
|
semanticCommitType: 'feat',
|
|
|
|
},
|
|
|
|
patch: {
|
|
|
|
semanticCommitType: 'fix',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.packageRules).toHaveLength(3);
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2022-07-26 05:25:37 +00:00
|
|
|
it('filters packageRules with only match/exclude', () => {
|
|
|
|
const config: RenovateConfig = {
|
|
|
|
packageRules: [
|
|
|
|
{
|
|
|
|
matchBaseBranches: ['main'],
|
|
|
|
major: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
|
|
|
expect(res.packageRules).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
2021-09-01 13:23:39 +00:00
|
|
|
it('does not massage lockFileMaintenance', () => {
|
|
|
|
const config: RenovateConfig = {
|
|
|
|
packageRules: [
|
|
|
|
{
|
|
|
|
matchManagers: ['helmv3'],
|
|
|
|
matchBaseBranches: ['release/ft10/1.9.x'],
|
|
|
|
lockFileMaintenance: { enabled: true },
|
|
|
|
schedule: ['at any time'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.packageRules).toHaveLength(1);
|
|
|
|
});
|
2017-08-15 11:26:05 +00:00
|
|
|
});
|
|
|
|
});
|