2022-06-20 15:05:39 +00:00
|
|
|
import { Fixtures } from '../../../../test/fixtures';
|
2021-11-22 08:03:38 +00:00
|
|
|
import { extractPackageFile } from '.';
|
2017-12-05 06:50:16 +00:00
|
|
|
|
2022-06-20 15:05:39 +00:00
|
|
|
const invalidYAML = Fixtures.get('invalid.yml');
|
|
|
|
const matrixYAMLwithNodeSyntaxString = Fixtures.get('matrix_jobs.yml');
|
|
|
|
const matrixYAMLwithNodeSyntaxArray = Fixtures.get('matrix_jobs_array.yml');
|
|
|
|
const matrixYAMLwithNodeSyntaxArray2 = Fixtures.get('matrix_jobs_array2.yml');
|
|
|
|
const matrixYAMLwithNodeSyntaxAlias = Fixtures.get('matrix_alias.yml');
|
|
|
|
const invalidMatrixYAML = Fixtures.get('matrix_invalid.yml');
|
2019-07-27 06:28:48 +00:00
|
|
|
|
2022-03-03 09:35:26 +00:00
|
|
|
describe('modules/manager/travis/extract', () => {
|
2018-11-04 17:51:23 +00:00
|
|
|
describe('extractPackageFile()', () => {
|
2018-05-03 16:09:18 +00:00
|
|
|
it('returns empty if fails to parse', () => {
|
2019-07-17 08:14:56 +00:00
|
|
|
const res = extractPackageFile('blahhhhh:foo:@what\n');
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(res).toBeNull();
|
2017-12-05 06:50:16 +00:00
|
|
|
});
|
2021-11-22 08:03:38 +00:00
|
|
|
|
2018-05-09 06:03:59 +00:00
|
|
|
it('returns results', () => {
|
2019-07-17 08:14:56 +00:00
|
|
|
const res = extractPackageFile('node_js:\n - 6\n - 8\n');
|
2018-05-09 06:03:59 +00:00
|
|
|
expect(res).toMatchSnapshot();
|
2022-06-20 15:05:39 +00:00
|
|
|
expect(res?.deps).toHaveLength(2);
|
2018-05-09 06:03:59 +00:00
|
|
|
});
|
2021-11-22 08:03:38 +00:00
|
|
|
|
2019-07-27 06:28:48 +00:00
|
|
|
it('should handle invalid YAML', () => {
|
|
|
|
const res = extractPackageFile(invalidYAML);
|
|
|
|
expect(res).toBeNull();
|
|
|
|
});
|
2021-11-22 08:03:38 +00:00
|
|
|
|
|
|
|
it('handles matrix node_js syntax with node_js string', () => {
|
|
|
|
const res = extractPackageFile(matrixYAMLwithNodeSyntaxString);
|
|
|
|
expect(res).toEqual({
|
|
|
|
deps: [
|
|
|
|
{
|
|
|
|
currentValue: '11.10.1',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles matrix node_js syntax with node_js array', () => {
|
|
|
|
const res = extractPackageFile(matrixYAMLwithNodeSyntaxArray);
|
|
|
|
expect(res).toEqual({
|
|
|
|
deps: [
|
|
|
|
{
|
|
|
|
currentValue: '11.10.1',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
currentValue: '11.10.2',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles matrix node_js syntax with node_js array 2', () => {
|
|
|
|
const res = extractPackageFile(matrixYAMLwithNodeSyntaxArray2);
|
|
|
|
expect(res).toEqual({
|
|
|
|
deps: [
|
|
|
|
{
|
|
|
|
currentValue: '11.10.1',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
currentValue: '11.10.2',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles matrix node_js syntax with alias', () => {
|
|
|
|
const res = extractPackageFile(matrixYAMLwithNodeSyntaxAlias);
|
|
|
|
expect(res).toEqual({
|
|
|
|
deps: [
|
|
|
|
{
|
|
|
|
currentValue: '11.10.1',
|
2024-01-29 14:29:22 +00:00
|
|
|
datasource: 'node-version',
|
2021-11-22 08:03:38 +00:00
|
|
|
depName: 'node',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles invalid matrix node_js syntax', () => {
|
|
|
|
const res = extractPackageFile(invalidMatrixYAML);
|
|
|
|
expect(res).toBeNull();
|
|
|
|
});
|
2017-12-05 06:50:16 +00:00
|
|
|
});
|
|
|
|
});
|