mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
test(workers/branch): Explicit conditions for snapshots (#13085)
This commit is contained in:
parent
6d956a3c1d
commit
b762656b7f
2 changed files with 110 additions and 59 deletions
|
@ -8,7 +8,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "version: 0.0.2",
|
"contents": "version: 0.0.2",
|
||||||
"name": "undefined",
|
"name": "Chart.yaml",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "new version",
|
"contents": "new version",
|
||||||
"name": "undefined",
|
"name": "package.json",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "updated-file",
|
"contents": "updated-file",
|
||||||
"name": "undefined",
|
"name": "index.html",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -50,21 +50,12 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "updated-file",
|
"contents": "updated-file",
|
||||||
"name": "undefined",
|
"name": "index.html",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles autoreplace branch no update 1`] = `
|
|
||||||
Object {
|
|
||||||
"artifactErrors": Array [],
|
|
||||||
"reuseExistingBranch": undefined,
|
|
||||||
"updatedArtifacts": Array [],
|
|
||||||
"updatedPackageFiles": Array [],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles content change 1`] = `
|
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles content change 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"artifactErrors": Array [],
|
"artifactErrors": Array [],
|
||||||
|
@ -73,21 +64,12 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "some new content",
|
"contents": "some new content",
|
||||||
"name": "undefined",
|
"name": "package.json",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles empty 1`] = `
|
|
||||||
Object {
|
|
||||||
"artifactErrors": Array [],
|
|
||||||
"reuseExistingBranch": undefined,
|
|
||||||
"updatedArtifacts": Array [],
|
|
||||||
"updatedPackageFiles": Array [],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles git submodules 1`] = `
|
exports[`workers/branch/get-updated getUpdatedPackageFiles() handles git submodules 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"artifactErrors": Array [],
|
"artifactErrors": Array [],
|
||||||
|
@ -96,7 +78,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "existing content",
|
"contents": "existing content",
|
||||||
"name": "undefined",
|
"name": ".gitmodules",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -162,7 +144,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "some new content",
|
"contents": "some new content",
|
||||||
"name": "undefined",
|
"name": "composer.json",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -209,7 +191,7 @@ Object {
|
||||||
"updatedPackageFiles": Array [
|
"updatedPackageFiles": Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "existing content",
|
"contents": "existing content",
|
||||||
"name": "undefined",
|
"name": "composer.json",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,31 @@ describe('workers/branch/get-updated', () => {
|
||||||
git.getFile.mockResolvedValueOnce('existing content');
|
git.getFile.mockResolvedValueOnce('existing content');
|
||||||
});
|
});
|
||||||
it('handles autoreplace base updated', async () => {
|
it('handles autoreplace base updated', async () => {
|
||||||
config.upgrades.push({ manager: 'html', branchName: undefined });
|
config.upgrades.push({
|
||||||
|
packageFile: 'index.html',
|
||||||
|
manager: 'html',
|
||||||
|
branchName: undefined,
|
||||||
|
});
|
||||||
autoReplace.doAutoReplace.mockResolvedValueOnce('updated-file');
|
autoReplace.doAutoReplace.mockResolvedValueOnce('updated-file');
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [{ name: 'index.html', contents: 'updated-file' }],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles autoreplace branch no update', async () => {
|
it('handles autoreplace branch no update', async () => {
|
||||||
config.upgrades.push({ manager: 'html', branchName: undefined });
|
config.upgrades.push({
|
||||||
|
packageFile: 'index.html',
|
||||||
|
manager: 'html',
|
||||||
|
branchName: undefined,
|
||||||
|
});
|
||||||
autoReplace.doAutoReplace.mockResolvedValueOnce('existing content');
|
autoReplace.doAutoReplace.mockResolvedValueOnce('existing content');
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toEqual({
|
||||||
expect(res).toMatchSnapshot();
|
artifactErrors: [],
|
||||||
|
reuseExistingBranch: undefined,
|
||||||
|
updatedArtifacts: [],
|
||||||
|
updatedPackageFiles: [],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles autoreplace failure', async () => {
|
it('handles autoreplace failure', async () => {
|
||||||
config.upgrades.push({ manager: 'html', branchName: undefined });
|
config.upgrades.push({ manager: 'html', branchName: undefined });
|
||||||
|
@ -53,17 +66,26 @@ describe('workers/branch/get-updated', () => {
|
||||||
});
|
});
|
||||||
it('handles autoreplace branch needs update', async () => {
|
it('handles autoreplace branch needs update', async () => {
|
||||||
config.reuseExistingBranch = true;
|
config.reuseExistingBranch = true;
|
||||||
config.upgrades.push({ manager: 'html', branchName: undefined });
|
config.upgrades.push({
|
||||||
|
packageFile: 'index.html',
|
||||||
|
manager: 'html',
|
||||||
|
branchName: undefined,
|
||||||
|
});
|
||||||
autoReplace.doAutoReplace.mockResolvedValueOnce(null);
|
autoReplace.doAutoReplace.mockResolvedValueOnce(null);
|
||||||
autoReplace.doAutoReplace.mockResolvedValueOnce('updated-file');
|
autoReplace.doAutoReplace.mockResolvedValueOnce('updated-file');
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [{ contents: 'updated-file', name: 'index.html' }],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles empty', async () => {
|
it('handles empty', async () => {
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toEqual({
|
||||||
expect(res).toMatchSnapshot();
|
artifactErrors: [],
|
||||||
|
reuseExistingBranch: undefined,
|
||||||
|
updatedArtifacts: [],
|
||||||
|
updatedPackageFiles: [],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles null content', async () => {
|
it('handles null content', async () => {
|
||||||
config.reuseExistingBranch = true;
|
config.reuseExistingBranch = true;
|
||||||
|
@ -75,16 +97,21 @@ describe('workers/branch/get-updated', () => {
|
||||||
it('handles content change', async () => {
|
it('handles content change', async () => {
|
||||||
config.reuseExistingBranch = true;
|
config.reuseExistingBranch = true;
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: 'package.json',
|
||||||
manager: 'npm',
|
manager: 'npm',
|
||||||
} as never);
|
} as never);
|
||||||
npm.updateDependency.mockReturnValue('some new content');
|
npm.updateDependency.mockReturnValue('some new content');
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{ name: 'package.json', contents: 'some new content' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles lock files', async () => {
|
it('handles lock files', async () => {
|
||||||
config.reuseExistingBranch = true;
|
config.reuseExistingBranch = true;
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: 'composer.json',
|
||||||
manager: 'composer',
|
manager: 'composer',
|
||||||
branchName: undefined,
|
branchName: undefined,
|
||||||
});
|
});
|
||||||
|
@ -98,8 +125,14 @@ describe('workers/branch/get-updated', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedArtifacts: [
|
||||||
|
{ name: 'composer.json', contents: 'some contents' },
|
||||||
|
],
|
||||||
|
updatedPackageFiles: [
|
||||||
|
{ name: 'composer.json', contents: 'some new content' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles lockFileMaintenance', async () => {
|
it('handles lockFileMaintenance', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
@ -115,8 +148,11 @@ describe('workers/branch/get-updated', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedArtifacts: [
|
||||||
|
{ name: 'composer.json', contents: 'some contents' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles isRemediation success', async () => {
|
it('handles isRemediation success', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
@ -127,8 +163,11 @@ describe('workers/branch/get-updated', () => {
|
||||||
'package-lock.json': 'new contents',
|
'package-lock.json': 'new contents',
|
||||||
});
|
});
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{ name: 'package-lock.json', contents: 'new contents' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles isRemediation rebase', async () => {
|
it('handles isRemediation rebase', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
@ -141,8 +180,11 @@ describe('workers/branch/get-updated', () => {
|
||||||
'package-lock.json': 'new contents',
|
'package-lock.json': 'new contents',
|
||||||
});
|
});
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{ name: 'package-lock.json', contents: 'new contents' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles lockFileMaintenance error', async () => {
|
it('handles lockFileMaintenance error', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
@ -158,8 +200,9 @@ describe('workers/branch/get-updated', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
artifactErrors: [{ lockFile: 'composer.lock', stderr: 'some error' }],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles lock file errors', async () => {
|
it('handles lock file errors', async () => {
|
||||||
config.reuseExistingBranch = true;
|
config.reuseExistingBranch = true;
|
||||||
|
@ -177,21 +220,27 @@ describe('workers/branch/get-updated', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
artifactErrors: [{ lockFile: 'composer.lock', stderr: 'some error' }],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('handles git submodules', async () => {
|
it('handles git submodules', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: '.gitmodules',
|
||||||
manager: 'git-submodules',
|
manager: 'git-submodules',
|
||||||
datasource: GitRefsDatasource.id,
|
datasource: GitRefsDatasource.id,
|
||||||
} as never);
|
} as never);
|
||||||
gitSubmodules.updateDependency.mockResolvedValueOnce('existing content');
|
gitSubmodules.updateDependency.mockResolvedValueOnce('existing content');
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{ name: '.gitmodules', contents: 'existing content' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('update artifacts on update-lockfile strategy', async () => {
|
it('update artifacts on update-lockfile strategy', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: 'composer.json',
|
||||||
manager: 'composer',
|
manager: 'composer',
|
||||||
branchName: undefined,
|
branchName: undefined,
|
||||||
rangeStrategy: 'update-lockfile',
|
rangeStrategy: 'update-lockfile',
|
||||||
|
@ -206,11 +255,18 @@ describe('workers/branch/get-updated', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedArtifacts: [
|
||||||
|
{ name: 'composer.lock', contents: 'some contents' },
|
||||||
|
],
|
||||||
|
updatedPackageFiles: [
|
||||||
|
{ name: 'composer.json', contents: 'existing content' },
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('bumps versions in updateDependency managers', async () => {
|
it('bumps versions in updateDependency managers', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: 'package.json',
|
||||||
branchName: undefined,
|
branchName: undefined,
|
||||||
bumpVersion: 'patch',
|
bumpVersion: 'patch',
|
||||||
manager: 'npm',
|
manager: 'npm',
|
||||||
|
@ -218,11 +274,18 @@ describe('workers/branch/get-updated', () => {
|
||||||
npm.updateDependency.mockReturnValue('old version');
|
npm.updateDependency.mockReturnValue('old version');
|
||||||
npm.bumpPackageVersion.mockReturnValue({ bumpedContent: 'new version' });
|
npm.bumpPackageVersion.mockReturnValue({ bumpedContent: 'new version' });
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{
|
||||||
|
name: 'package.json',
|
||||||
|
contents: 'new version',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it('bumps versions in autoReplace managers', async () => {
|
it('bumps versions in autoReplace managers', async () => {
|
||||||
config.upgrades.push({
|
config.upgrades.push({
|
||||||
|
packageFile: 'Chart.yaml',
|
||||||
branchName: undefined,
|
branchName: undefined,
|
||||||
bumpVersion: 'patch',
|
bumpVersion: 'patch',
|
||||||
manager: 'helmv3',
|
manager: 'helmv3',
|
||||||
|
@ -232,8 +295,14 @@ describe('workers/branch/get-updated', () => {
|
||||||
bumpedContent: 'version: 0.0.2',
|
bumpedContent: 'version: 0.0.2',
|
||||||
});
|
});
|
||||||
const res = await getUpdatedPackageFiles(config);
|
const res = await getUpdatedPackageFiles(config);
|
||||||
// FIXME: explicit assert condition
|
expect(res).toMatchSnapshot({
|
||||||
expect(res).toMatchSnapshot();
|
updatedPackageFiles: [
|
||||||
|
{
|
||||||
|
contents: 'version: 0.0.2',
|
||||||
|
name: 'Chart.yaml',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue