test: Refactor more snapshot test (#11313)

This commit is contained in:
Sergei Zharinov 2021-08-18 09:49:27 +03:00 committed by GitHub
parent 5f4b9f9a3a
commit b21439fb75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 331 additions and 270 deletions

View file

@ -276,7 +276,6 @@ describe('manager/composer/artifacts', () => {
fs.writeLocalFile.mockImplementationOnce(() => { fs.writeLocalFile.mockImplementationOnce(() => {
throw new Error('not found'); throw new Error('not found');
}); });
// FIXME: explicit assert condition
expect( expect(
await composer.updateArtifacts({ await composer.updateArtifacts({
packageFileName: 'composer.json', packageFileName: 'composer.json',
@ -284,17 +283,16 @@ describe('manager/composer/artifacts', () => {
newPackageFileContent: '{}', newPackageFileContent: '{}',
config, config,
}) })
).toMatchSnapshot(); ).toMatchSnapshot([{ artifactError: { lockFile: 'composer.lock' } }]);
}); });
it('catches unmet requirements errors', async () => { it('catches unmet requirements errors', async () => {
const stderr =
'fooYour requirements could not be resolved to an installable set of packages.bar';
fs.readLocalFile.mockResolvedValueOnce('{}'); fs.readLocalFile.mockResolvedValueOnce('{}');
fs.writeLocalFile.mockImplementationOnce(() => { fs.writeLocalFile.mockImplementationOnce(() => {
throw new Error( throw new Error(stderr);
'fooYour requirements could not be resolved to an installable set of packages.bar'
);
}); });
// FIXME: explicit assert condition
expect( expect(
await composer.updateArtifacts({ await composer.updateArtifacts({
packageFileName: 'composer.json', packageFileName: 'composer.json',
@ -302,7 +300,9 @@ describe('manager/composer/artifacts', () => {
newPackageFileContent: '{}', newPackageFileContent: '{}',
config, config,
}) })
).toMatchSnapshot(); ).toMatchSnapshot([
{ artifactError: { lockFile: 'composer.lock', stderr } },
]);
}); });
it('throws for disk space', async () => { it('throws for disk space', async () => {

View file

@ -24,8 +24,8 @@ describe('manager/composer/extract', () => {
}); });
it('extracts dependencies with no lock file', async () => { it('extracts dependencies with no lock file', async () => {
const res = await extractPackageFile(requirements1, packageFile); const res = await extractPackageFile(requirements1, packageFile);
// FIXME: explicit assert condition
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res.deps).toHaveLength(32);
}); });
it('extracts registryUrls', async () => { it('extracts registryUrls', async () => {
const res = await extractPackageFile(requirements2, packageFile); const res = await extractPackageFile(requirements2, packageFile);
@ -51,8 +51,8 @@ describe('manager/composer/extract', () => {
it('extracts dependencies with lock file', async () => { it('extracts dependencies with lock file', async () => {
fs.readLocalFile.mockResolvedValue('some content'); fs.readLocalFile.mockResolvedValue('some content');
const res = await extractPackageFile(requirements1, packageFile); const res = await extractPackageFile(requirements1, packageFile);
// FIXME: explicit assert condition
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res.deps).toHaveLength(32);
}); });
}); });
}); });

View file

@ -1,80 +1,78 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`manager/deps-edn/extract extractPackageFile 1`] = ` exports[`manager/deps-edn/extract extractPackageFile 1`] = `
Object { Array [
"deps": Array [ Object {
Object { "currentValue": "0.1.2",
"currentValue": "0.1.2", "datasource": "clojure",
"datasource": "clojure", "depName": "persistent-sorted-set:persistent-sorted-set",
"depName": "persistent-sorted-set:persistent-sorted-set", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "1.9.0",
"currentValue": "1.9.0", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:clojure",
"depName": "org.clojure:clojure", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "1.10.0",
"currentValue": "1.10.0", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:clojure",
"depName": "org.clojure:clojure", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "1.10.520",
"currentValue": "1.10.520", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:clojurescript",
"depName": "org.clojure:clojurescript", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.2.11",
"currentValue": "0.2.11", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:tools.namespace",
"depName": "org.clojure:tools.namespace", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "1.10.520",
"currentValue": "1.10.520", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:clojurescript",
"depName": "org.clojure:clojurescript", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.0-389",
"currentValue": "0.0-389", "datasource": "clojure",
"datasource": "clojure", "depName": "lambdaisland:kaocha",
"depName": "lambdaisland:kaocha", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.0-21",
"currentValue": "0.0-21", "datasource": "clojure",
"datasource": "clojure", "depName": "lambdaisland:kaocha-cljs",
"depName": "lambdaisland:kaocha-cljs", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.21.1",
"currentValue": "0.21.1", "datasource": "clojure",
"datasource": "clojure", "depName": "cider:cider-nrepl",
"depName": "cider:cider-nrepl", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.6.0",
"currentValue": "0.6.0", "datasource": "clojure",
"datasource": "clojure", "depName": "nrepl:nrepl",
"depName": "nrepl:nrepl", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.2.11",
"currentValue": "0.2.11", "datasource": "clojure",
"datasource": "clojure", "depName": "org.clojure:tools.namespace",
"depName": "org.clojure:tools.namespace", "registryUrls": Array [],
"registryUrls": Array [], },
}, Object {
Object { "currentValue": "0.9.5703",
"currentValue": "0.9.5703", "datasource": "clojure",
"datasource": "clojure", "depName": "com.datomic:datomic-free",
"depName": "com.datomic:datomic-free", "registryUrls": Array [],
"registryUrls": Array [], },
}, ]
],
}
`; `;

View file

@ -5,7 +5,56 @@ const depsEdn = loadFixture('deps.edn');
describe('manager/deps-edn/extract', () => { describe('manager/deps-edn/extract', () => {
it('extractPackageFile', () => { it('extractPackageFile', () => {
// FIXME: explicit assert condition const { deps } = extractPackageFile(depsEdn);
expect(extractPackageFile(depsEdn)).toMatchSnapshot(); expect(deps).toMatchSnapshot([
{
depName: 'persistent-sorted-set:persistent-sorted-set',
currentValue: '0.1.2',
},
{
depName: 'org.clojure:clojure',
currentValue: '1.9.0',
},
{
depName: 'org.clojure:clojure',
currentValue: '1.10.0',
},
{
depName: 'org.clojure:clojurescript',
currentValue: '1.10.520',
},
{
depName: 'org.clojure:tools.namespace',
currentValue: '0.2.11',
},
{
depName: 'org.clojure:clojurescript',
currentValue: '1.10.520',
},
{
depName: 'lambdaisland:kaocha',
currentValue: '0.0-389',
},
{
depName: 'lambdaisland:kaocha-cljs',
currentValue: '0.0-21',
},
{
depName: 'cider:cider-nrepl',
currentValue: '0.21.1',
},
{
depName: 'nrepl:nrepl',
currentValue: '0.6.0',
},
{
depName: 'org.clojure:tools.namespace',
currentValue: '0.2.11',
},
{
depName: 'com.datomic:datomic-free',
currentValue: '0.9.5703',
},
]);
}); });
}); });

View file

@ -457,9 +457,3 @@ Array [
}, },
] ]
`; `;
exports[`manager/dockerfile/extract getDep() rejects null 1`] = `
Object {
"skipReason": "invalid-value",
}
`;

View file

@ -12,58 +12,113 @@ describe('manager/dockerfile/extract', () => {
}); });
it('handles naked dep', () => { it('handles naked dep', () => {
const res = extractPackageFile('FROM node\n').deps; const res = extractPackageFile('FROM node\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: undefined,
datasource: 'docker',
depName: 'node',
depType: 'final',
replaceString: 'node',
},
]);
}); });
it('is case insensitive', () => { it('is case insensitive', () => {
const res = extractPackageFile('From node\n').deps; const res = extractPackageFile('From node\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentDigest: undefined,
currentValue: undefined,
depName: 'node',
},
]);
}); });
it('handles tag', () => { it('handles tag', () => {
const res = extractPackageFile('FROM node:8.9.0-alpine\n').deps; const res = extractPackageFile('FROM node:8.9.0-alpine\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8.9.0-alpine',
depName: 'node',
replaceString: 'node:8.9.0-alpine',
},
]);
}); });
it('handles digest', () => { it('handles digest', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM node@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063\n' 'FROM node@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentDigest:
'sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063',
depName: 'node',
replaceString:
'node@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063',
},
]);
}); });
it('handles tag and digest', () => { it('handles tag and digest', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM node:8.9.0@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063\n' 'FROM node:8.9.0@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentDigest:
'sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063',
currentValue: '8.9.0',
depName: 'node',
replaceString:
'node:8.9.0@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063',
},
]);
}); });
it('handles from as', () => { it('handles from as', () => {
const res = extractPackageFile('FROM node:8.9.0-alpine as base\n').deps; const res = extractPackageFile('FROM node:8.9.0-alpine as base\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8.9.0-alpine',
depName: 'node',
replaceString: 'node:8.9.0-alpine',
},
]);
}); });
it('handles comments', () => { it('handles comments', () => {
const res = extractPackageFile( const res = extractPackageFile(
'# some comment\n# another\n\nFROM node\n' '# some comment\n# another\n\nFROM node\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentDigest: undefined,
currentValue: undefined,
depName: 'node',
},
]);
}); });
it('handles custom hosts', () => { it('handles custom hosts', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM registry2.something.info/node:8\n' 'FROM registry2.something.info/node:8\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8',
depName: 'registry2.something.info/node',
replaceString: 'registry2.something.info/node:8',
},
]);
}); });
it('handles custom hosts and suffix', () => { it('handles custom hosts and suffix', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM registry2.something.info/node:8-alpine\n' 'FROM registry2.something.info/node:8-alpine\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8-alpine',
depName: 'registry2.something.info/node',
replaceString: 'registry2.something.info/node:8-alpine',
},
]);
}); });
it('handles custom hosts with port', () => { it('handles custom hosts with port', () => {
const res = extractPackageFile( const res = extractPackageFile(
@ -91,22 +146,38 @@ describe('manager/dockerfile/extract', () => {
}); });
it('handles namespaced images', () => { it('handles namespaced images', () => {
const res = extractPackageFile('FROM mynamespace/node:8\n').deps; const res = extractPackageFile('FROM mynamespace/node:8\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8',
depName: 'mynamespace/node',
replaceString: 'mynamespace/node:8',
},
]);
}); });
it('handles custom hosts with namespace', () => { it('handles custom hosts with namespace', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM registry2.something.info/someaccount/node:8\n' 'FROM registry2.something.info/someaccount/node:8\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8',
datasource: 'docker',
depName: 'registry2.something.info/someaccount/node',
replaceString: 'registry2.something.info/someaccount/node:8',
},
]);
}); });
it('handles abnormal spacing', () => { it('handles abnormal spacing', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM registry.allmine.info:5005/node:8.7.0\n\n' 'FROM registry.allmine.info:5005/node:8.7.0\n\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '8.7.0',
depName: 'registry.allmine.info:5005/node',
replaceString: 'registry.allmine.info:5005/node:8.7.0',
},
]);
}); });
it('extracts multiple FROM tags', () => { it('extracts multiple FROM tags', () => {
const res = extractPackageFile( const res = extractPackageFile(
@ -130,8 +201,13 @@ describe('manager/dockerfile/extract', () => {
const res = extractPackageFile( const res = extractPackageFile(
'FROM scratch\nCOPY --from=gcr.io/k8s-skaffold/skaffold:v0.11.0 /usr/bin/skaffold /usr/bin/skaffold\n' 'FROM scratch\nCOPY --from=gcr.io/k8s-skaffold/skaffold:v0.11.0 /usr/bin/skaffold /usr/bin/skaffold\n'
).deps; ).deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: 'v0.11.0',
depName: 'gcr.io/k8s-skaffold/skaffold',
replaceString: 'gcr.io/k8s-skaffold/skaffold:v0.11.0',
},
]);
}); });
it('skips named multistage COPY --from tags', () => { it('skips named multistage COPY --from tags', () => {
const res = extractPackageFile( const res = extractPackageFile(
@ -171,19 +247,28 @@ describe('manager/dockerfile/extract', () => {
}); });
it('handles calico/node', () => { it('handles calico/node', () => {
const res = extractPackageFile('FROM calico/node\n').deps; const res = extractPackageFile('FROM calico/node\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
datasource: 'docker',
depName: 'calico/node',
replaceString: 'calico/node',
},
]);
}); });
it('handles ubuntu', () => { it('handles ubuntu', () => {
const res = extractPackageFile('FROM ubuntu:18.04\n').deps; const res = extractPackageFile('FROM ubuntu:18.04\n').deps;
// FIXME: explicit assert condition expect(res).toMatchSnapshot([
expect(res).toMatchSnapshot(); {
currentValue: '18.04',
depName: 'ubuntu',
versioning: 'ubuntu',
},
]);
}); });
}); });
describe('getDep()', () => { describe('getDep()', () => {
it('rejects null', () => { it('rejects null', () => {
// FIXME: explicit assert condition expect(getDep(null)).toEqual({ skipReason: 'invalid-value' });
expect(getDep(null)).toMatchSnapshot();
}); });
}); });
}); });

View file

@ -3,7 +3,6 @@ import updateArtifacts from './artifacts';
describe('manager/git-submodules/artifact', () => { describe('manager/git-submodules/artifact', () => {
describe('updateArtifacts()', () => { describe('updateArtifacts()', () => {
it('returns empty content', () => { it('returns empty content', () => {
// FIXME: explicit assert condition
expect( expect(
updateArtifacts({ updateArtifacts({
packageFileName: '', packageFileName: '',
@ -11,10 +10,9 @@ describe('manager/git-submodules/artifact', () => {
newPackageFileContent: '', newPackageFileContent: '',
config: {}, config: {},
}) })
).toMatchSnapshot(); ).toMatchSnapshot([{ file: { contents: '', name: '' } }]);
}); });
it('returns two modules', () => { it('returns two modules', () => {
// FIXME: explicit assert condition
expect( expect(
updateArtifacts({ updateArtifacts({
packageFileName: '', packageFileName: '',
@ -22,7 +20,10 @@ describe('manager/git-submodules/artifact', () => {
newPackageFileContent: '', newPackageFileContent: '',
config: {}, config: {},
}) })
).toMatchSnapshot(); ).toMatchSnapshot([
{ file: { name: 'renovate' } },
{ file: { name: 'renovate-pro' } },
]);
}); });
}); });
}); });

View file

@ -1,17 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`manager/gomod/artifacts catches errors 1`] = ` exports[`manager/gomod/artifacts catches errors 1`] = `Array []`;
Array [
Object {
"artifactError": Object {
"lockFile": "go.sum",
"stderr": "This update totally doesnt work",
},
},
]
`;
exports[`manager/gomod/artifacts catches errors 2`] = `Array []`;
exports[`manager/gomod/artifacts returns if no go.sum found 1`] = `Array []`; exports[`manager/gomod/artifacts returns if no go.sum found 1`] = `Array []`;
@ -76,23 +65,6 @@ Array [
`; `;
exports[`manager/gomod/artifacts skips updating import paths for gopkg.in dependencies 1`] = ` exports[`manager/gomod/artifacts skips updating import paths for gopkg.in dependencies 1`] = `
Array [
Object {
"file": Object {
"contents": "New go.sum",
"name": "go.sum",
},
},
Object {
"file": Object {
"contents": "New go.mod",
"name": "go.mod",
},
},
]
`;
exports[`manager/gomod/artifacts skips updating import paths for gopkg.in dependencies 2`] = `
Array [ Array [
Object { Object {
"cmd": "go get -d ./...", "cmd": "go get -d ./...",
@ -173,23 +145,6 @@ Array [
`; `;
exports[`manager/gomod/artifacts skips updating import paths with gomodUpdateImportPaths on v0 to v1 1`] = ` exports[`manager/gomod/artifacts skips updating import paths with gomodUpdateImportPaths on v0 to v1 1`] = `
Array [
Object {
"file": Object {
"contents": "New go.sum",
"name": "go.sum",
},
},
Object {
"file": Object {
"contents": "New go.mod",
"name": "go.mod",
},
},
]
`;
exports[`manager/gomod/artifacts skips updating import paths with gomodUpdateImportPaths on v0 to v1 2`] = `
Array [ Array [
Object { Object {
"cmd": "go get -d ./...", "cmd": "go get -d ./...",
@ -556,29 +511,6 @@ Array [
`; `;
exports[`manager/gomod/artifacts updates import paths with gomodUpdateImportPaths 1`] = ` exports[`manager/gomod/artifacts updates import paths with gomodUpdateImportPaths 1`] = `
Array [
Object {
"file": Object {
"contents": "New go.sum",
"name": "go.sum",
},
},
Object {
"file": Object {
"contents": "New main.go",
"name": "main.go",
},
},
Object {
"file": Object {
"contents": "New go.mod",
"name": "go.mod",
},
},
]
`;
exports[`manager/gomod/artifacts updates import paths with gomodUpdateImportPaths 2`] = `
Array [ Array [
Object { Object {
"cmd": "go get -d ./...", "cmd": "go get -d ./...",
@ -709,29 +641,6 @@ Array [
`; `;
exports[`manager/gomod/artifacts updates import paths with latest tool version on invalid version constraint 1`] = ` exports[`manager/gomod/artifacts updates import paths with latest tool version on invalid version constraint 1`] = `
Array [
Object {
"file": Object {
"contents": "New go.sum",
"name": "go.sum",
},
},
Object {
"file": Object {
"contents": "New main.go",
"name": "main.go",
},
},
Object {
"file": Object {
"contents": "New go.mod",
"name": "go.mod",
},
},
]
`;
exports[`manager/gomod/artifacts updates import paths with latest tool version on invalid version constraint 2`] = `
Array [ Array [
Object { Object {
"cmd": "go get -d ./...", "cmd": "go get -d ./...",
@ -862,29 +771,6 @@ Array [
`; `;
exports[`manager/gomod/artifacts updates import paths with specific tool version from constraint 1`] = ` exports[`manager/gomod/artifacts updates import paths with specific tool version from constraint 1`] = `
Array [
Object {
"file": Object {
"contents": "New go.sum",
"name": "go.sum",
},
},
Object {
"file": Object {
"contents": "New main.go",
"name": "main.go",
},
},
Object {
"file": Object {
"contents": "New go.mod",
"name": "go.mod",
},
},
]
`;
exports[`manager/gomod/artifacts updates import paths with specific tool version from constraint 2`] = `
Array [ Array [
Object { Object {
"cmd": "go get -d ./...", "cmd": "go get -d ./...",

View file

@ -243,7 +243,6 @@ describe('manager/gomod/artifacts', () => {
fs.outputFile.mockImplementationOnce(() => { fs.outputFile.mockImplementationOnce(() => {
throw new Error('This update totally doesnt work'); throw new Error('This update totally doesnt work');
}); });
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -251,7 +250,14 @@ describe('manager/gomod/artifacts', () => {
newPackageFileContent: gomod1, newPackageFileContent: gomod1,
config, config,
}) })
).toMatchSnapshot(); ).toEqual([
{
artifactError: {
lockFile: 'go.sum',
stderr: 'This update totally doesnt work',
},
},
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
it('updates import paths with gomodUpdateImportPaths', async () => { it('updates import paths with gomodUpdateImportPaths', async () => {
@ -265,7 +271,6 @@ describe('manager/gomod/artifacts', () => {
.mockResolvedValueOnce('New go.sum' as any) .mockResolvedValueOnce('New go.sum' as any)
.mockResolvedValueOnce('New main.go' as any) .mockResolvedValueOnce('New main.go' as any)
.mockResolvedValueOnce('New go.mod' as any); .mockResolvedValueOnce('New go.mod' as any);
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -278,7 +283,11 @@ describe('manager/gomod/artifacts', () => {
postUpdateOptions: ['gomodUpdateImportPaths'], postUpdateOptions: ['gomodUpdateImportPaths'],
}, },
}) })
).toMatchSnapshot(); ).toEqual([
{ file: { contents: 'New go.sum', name: 'go.sum' } },
{ file: { contents: 'New main.go', name: 'main.go' } },
{ file: { contents: 'New go.mod', name: 'go.mod' } },
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
it('skips updating import paths with gomodUpdateImportPaths on v0 to v1', async () => { it('skips updating import paths with gomodUpdateImportPaths on v0 to v1', async () => {
@ -291,7 +300,6 @@ describe('manager/gomod/artifacts', () => {
fs.readFile fs.readFile
.mockResolvedValueOnce('New go.sum' as any) .mockResolvedValueOnce('New go.sum' as any)
.mockResolvedValueOnce('New go.mod' as any); .mockResolvedValueOnce('New go.mod' as any);
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -304,7 +312,10 @@ describe('manager/gomod/artifacts', () => {
postUpdateOptions: ['gomodUpdateImportPaths'], postUpdateOptions: ['gomodUpdateImportPaths'],
}, },
}) })
).toMatchSnapshot(); ).toEqual([
{ file: { contents: 'New go.sum', name: 'go.sum' } },
{ file: { contents: 'New go.mod', name: 'go.mod' } },
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
it('updates import paths with specific tool version from constraint', async () => { it('updates import paths with specific tool version from constraint', async () => {
@ -318,7 +329,6 @@ describe('manager/gomod/artifacts', () => {
.mockResolvedValueOnce('New go.sum' as any) .mockResolvedValueOnce('New go.sum' as any)
.mockResolvedValueOnce('New main.go' as any) .mockResolvedValueOnce('New main.go' as any)
.mockResolvedValueOnce('New go.mod' as any); .mockResolvedValueOnce('New go.mod' as any);
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -334,7 +344,11 @@ describe('manager/gomod/artifacts', () => {
}, },
}, },
}) })
).toMatchSnapshot(); ).toEqual([
{ file: { contents: 'New go.sum', name: 'go.sum' } },
{ file: { contents: 'New main.go', name: 'main.go' } },
{ file: { contents: 'New go.mod', name: 'go.mod' } },
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
it('updates import paths with latest tool version on invalid version constraint', async () => { it('updates import paths with latest tool version on invalid version constraint', async () => {
@ -348,7 +362,6 @@ describe('manager/gomod/artifacts', () => {
.mockResolvedValueOnce('New go.sum' as any) .mockResolvedValueOnce('New go.sum' as any)
.mockResolvedValueOnce('New main.go' as any) .mockResolvedValueOnce('New main.go' as any)
.mockResolvedValueOnce('New go.mod' as any); .mockResolvedValueOnce('New go.mod' as any);
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -364,7 +377,11 @@ describe('manager/gomod/artifacts', () => {
}, },
}, },
}) })
).toMatchSnapshot(); ).toEqual([
{ file: { contents: 'New go.sum', name: 'go.sum' } },
{ file: { contents: 'New main.go', name: 'main.go' } },
{ file: { contents: 'New go.mod', name: 'go.mod' } },
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
it('skips updating import paths for gopkg.in dependencies', async () => { it('skips updating import paths for gopkg.in dependencies', async () => {
@ -377,7 +394,6 @@ describe('manager/gomod/artifacts', () => {
fs.readFile fs.readFile
.mockResolvedValueOnce('New go.sum' as any) .mockResolvedValueOnce('New go.sum' as any)
.mockResolvedValueOnce('New go.mod' as any); .mockResolvedValueOnce('New go.mod' as any);
// FIXME: explicit assert condition
expect( expect(
await gomod.updateArtifacts({ await gomod.updateArtifacts({
packageFileName: 'go.mod', packageFileName: 'go.mod',
@ -390,7 +406,10 @@ describe('manager/gomod/artifacts', () => {
postUpdateOptions: ['gomodUpdateImportPaths'], postUpdateOptions: ['gomodUpdateImportPaths'],
}, },
}) })
).toMatchSnapshot(); ).toEqual([
{ file: { contents: 'New go.sum', name: 'go.sum' } },
{ file: { contents: 'New go.mod', name: 'go.mod' } },
]);
expect(execSnapshots).toMatchSnapshot(); expect(execSnapshots).toMatchSnapshot();
}); });
}); });

View file

@ -62,9 +62,13 @@ describe('manager/helm-requirements/extract', () => {
stable: 'https://charts.helm.sh/stable/', stable: 'https://charts.helm.sh/stable/',
}, },
}); });
// FIXME: explicit assert condition expect(result).toMatchSnapshot({
expect(result).not.toBeNull(); datasource: 'helm',
expect(result).toMatchSnapshot(); deps: [
{ currentValue: '0.9.0', depName: 'redis' },
{ currentValue: '0.8.1', depName: 'postgresql' },
],
});
}); });
it('parses simple requirements.yaml but skips if necessary fields missing', () => { it('parses simple requirements.yaml but skips if necessary fields missing', () => {
fs.readLocalFile.mockResolvedValueOnce(` fs.readLocalFile.mockResolvedValueOnce(`
@ -132,9 +136,12 @@ describe('manager/helm-requirements/extract', () => {
stable: 'https://charts.helm.sh/stable/', stable: 'https://charts.helm.sh/stable/',
}, },
}); });
// FIXME: explicit assert condition expect(result).toMatchSnapshot({
expect(result).not.toBeNull(); deps: [
expect(result).toMatchSnapshot(); { depName: 'redis' },
{ depName: 'postgresql', skipReason: 'local-dependency' },
],
});
}); });
it('returns null if no dependencies', () => { it('returns null if no dependencies', () => {
fs.readLocalFile.mockResolvedValueOnce(` fs.readLocalFile.mockResolvedValueOnce(`

View file

@ -28,8 +28,14 @@ describe('manager/helm-values/extract', () => {
}); });
it('extracts from values.yaml correctly with same structure as "helm create"', () => { it('extracts from values.yaml correctly with same structure as "helm create"', () => {
const result = extractPackageFile(helmDefaultChartInitValues); const result = extractPackageFile(helmDefaultChartInitValues);
// FIXME: explicit assert condition expect(result).toMatchSnapshot({
expect(result).toMatchSnapshot(); deps: [
{
currentValue: '1.16.1',
depName: 'nginx',
},
],
});
}); });
it('extracts from complex values file correctly"', () => { it('extracts from complex values file correctly"', () => {
const result = extractPackageFile(helmMultiAndNestedImageValues); const result = extractPackageFile(helmMultiAndNestedImageValues);

View file

@ -81,9 +81,19 @@ describe('manager/helmfile/extract', () => {
stable: 'https://charts.helm.sh/stable', stable: 'https://charts.helm.sh/stable',
}, },
}); });
// FIXME: explicit assert condition expect(result).toMatchSnapshot({
expect(result).not.toBeNull(); datasource: 'helm',
expect(result).toMatchSnapshot(); deps: [
{
currentValue: '1.0.0',
skipReason: 'unsupported-chart-type',
},
{
currentValue: '1.0.0',
depName: 'example',
},
],
});
}); });
it('skip local charts', () => { it('skip local charts', () => {
@ -179,9 +189,15 @@ describe('manager/helmfile/extract', () => {
stable: 'https://charts.helm.sh/stable', stable: 'https://charts.helm.sh/stable',
}, },
}); });
// FIXME: explicit assert condition expect(result).toMatchSnapshot({
expect(result).not.toBeNull(); datasource: 'helm',
expect(result).toMatchSnapshot(); deps: [
{ skipReason: 'local-chart' },
{ depName: 'rabbitmq', currentValue: '7.4.3' },
{ depName: 'kube-prometheus-stack', currentValue: '13.7.2' },
{ depName: 'invalid', skipReason: 'invalid-name' },
],
});
}); });
}); });
}); });