Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions lib/modules/manager/circleci/__snapshots__/extract.spec.ts.snap

This file was deleted.

174 changes: 149 additions & 25 deletions lib/modules/manager/circleci/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]);
});
Expand Down