test(manager/circleci): remove snapshots and empty matchObjects tests (#30565)

This commit is contained in:
Sebastian Poxhofer 2024-08-05 12:11:22 +02:00 committed by GitHub
parent 607d7e3e1b
commit b667a4b8a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 149 additions and 67 deletions

View file

@ -1,42 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`modules/manager/circleci/extract extractPackageFile() extracts multiple image lines 1`] = `
[
{
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": undefined,
"datasource": "docker",
"depName": "node",
"depType": "docker",
"replaceString": "node",
},
{
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "4",
"datasource": "docker",
"depName": "node",
"depType": "docker",
"replaceString": "node:4",
},
{
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "6",
"datasource": "docker",
"depName": "node",
"depType": "docker",
"replaceString": "node:6",
},
{
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "8.9.0",
"datasource": "docker",
"depName": "node",
"depType": "docker",
"replaceString": "node:8.9.0",
},
]
`;

View file

@ -13,69 +13,193 @@ describe('modules/manager/circleci/extract', () => {
expect(extractPackageFile('nothing here')).toBeNull();
});
it('extracts multiple image lines', () => {
it('extracts multiple image and resolves yaml anchors', () => {
const res = extractPackageFile(file1);
expect(res?.deps).toMatchSnapshot();
expect(res?.deps).toHaveLength(4);
expect(res?.deps).toEqual([
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
datasource: 'docker',
depName: 'node',
depType: 'docker',
replaceString: 'node',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentValue: '4',
datasource: 'docker',
depName: 'node',
depType: 'docker',
replaceString: 'node:4',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentValue: '6',
datasource: 'docker',
depName: 'node',
depType: 'docker',
replaceString: 'node:6',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentValue: '8.9.0',
datasource: 'docker',
depName: 'node',
depType: 'docker',
replaceString: 'node:8.9.0',
},
]);
});
it('extracts orbs too', () => {
const res = extractPackageFile(file2);
expect(res?.deps).toMatchObject([
expect(res?.deps).toEqual([
{
depName: 'release-workflows',
currentValue: '4.1.0',
datasource: 'orb',
depName: 'release-workflows',
depType: 'orb',
packageName: 'hutson/library-release-workflows',
versioning: 'npm',
},
{
depName: 'no-version',
currentValue: undefined,
datasource: 'orb',
depName: 'no-version',
depType: 'orb',
packageName: 'abc/def',
versioning: 'npm',
},
{
depName: 'volatile',
currentValue: 'volatile',
datasource: 'orb',
depName: 'volatile',
depType: 'orb',
packageName: 'zzz/zzz',
versioning: 'npm',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
currentValue: '3.7',
datasource: 'docker',
depName: 'python',
depType: 'docker',
replaceString:
'python:3.7@sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
currentValue: '3.7',
datasource: 'docker',
depName: 'python',
depType: 'docker',
replaceString:
'python:3.7@sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
currentValue: '3.7',
datasource: 'docker',
depName: 'python',
depType: 'docker',
replaceString:
'python:3.7@sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
currentValue: '3.7',
datasource: 'docker',
depName: 'python',
depType: 'docker',
replaceString:
'python:3.7@sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:eb6325b75c1c70b4992eaa1bdd29e24e5f14d5324b4714a49f3e67783473214b',
currentValue: '3-6',
datasource: 'docker',
depName: 'pypy',
depType: 'docker',
replaceString:
'pypy:3-6@sha256:eb6325b75c1c70b4992eaa1bdd29e24e5f14d5324b4714a49f3e67783473214b',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest:
'sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
currentValue: '3.7',
datasource: 'docker',
depName: 'python',
depType: 'docker',
replaceString:
'python:3.7@sha256:3870d35b962a943df72d948580fc66ceaaee1c4fbd205930f32e0f0760eb1077',
},
{},
{},
{},
{},
{},
{},
]);
});
it('extracts image without leading dash', () => {
const res = extractPackageFile(file3);
expect(res?.deps).toMatchObject([
{ currentValue: '14.8.0', depName: 'cimg/node' },
{ currentValue: '14.8.0', depName: 'cimg/node' },
expect(res?.deps).toEqual([
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentValue: '14.8.0',
datasource: 'docker',
depName: 'cimg/node',
depType: 'docker',
replaceString: 'cimg/node:14.8.0',
},
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentValue: '14.8.0',
datasource: 'docker',
depName: 'cimg/node',
depType: 'docker',
replaceString: 'cimg/node:14.8.0',
},
]);
});
it('extracts and exclude android images', () => {
expect(
extractPackageFile(
'jobs:\n' +
' build:\n' +
' machine:\n' +
' image: android:202102-01',
),
extractPackageFile(codeBlock`
jobs:
build:
machine:
image: android:202102-01
`),
).toBeNull();
});
it('extracts orbs without jobs', () => {
const res = extractPackageFile(file4);
expect(res?.deps).toMatchObject([
expect(res?.deps).toEqual([
{
depName: 'nodejs',
currentValue: '5.2.0',
datasource: 'orb',
depName: 'nodejs',
depType: 'orb',
packageName: 'circleci/node',
versioning: 'npm',
},
]);
});