Skip to content

Commit

Permalink
fix(workers/repository): Pass correct lock files when updating a depe…
Browse files Browse the repository at this point in the history
…ndency in multiple input files (#27898)
  • Loading branch information
mbudnek authored Mar 15, 2024
1 parent 6cb7c81 commit a5193da
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
75 changes: 75 additions & 0 deletions lib/workers/repository/update/branch/get-updated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,81 @@ describe('workers/repository/update/branch/get-updated', () => {
});
});

it('for updatedArtifacts passes proper lockFiles', async () => {
config.upgrades.push({
packageFile: 'composer.json',
manager: 'composer',
branchName: '',
});
config.lockFiles = ['different.lock'];
config.packageFiles = {
composer: [
{
packageFile: 'composer.json',
lockFiles: ['composer.lock'],
deps: [],
},
] satisfies PackageFile[],
};
autoReplace.doAutoReplace.mockResolvedValueOnce('some new content');
composer.updateArtifacts.mockResolvedValueOnce([
{
file: {
type: 'addition',
path: 'composer.lock',
contents: 'some contents',
},
},
]);
await getUpdatedPackageFiles(config);
expect(composer.updateArtifacts).toHaveBeenCalledWith(
expect.objectContaining({
config: expect.objectContaining({
lockFiles: ['composer.lock'],
}),
}),
);
});

it('for nonUpdatedArtifacts passes proper lockFiles', async () => {
config.upgrades.push({
packageFile: 'composer.json',
manager: 'composer',
branchName: '',
isLockfileUpdate: true,
});
composer.updateLockedDependency.mockReturnValueOnce({
status: 'unsupported',
});
config.lockFiles = ['different.lock'];
config.packageFiles = {
composer: [
{
packageFile: 'composer.json',
lockFiles: ['composer.lock'],
deps: [],
},
] satisfies PackageFile[],
};
composer.updateArtifacts.mockResolvedValueOnce([
{
file: {
type: 'addition',
path: 'composer.lock',
contents: 'some contents',
},
},
]);
await getUpdatedPackageFiles(config);
expect(composer.updateArtifacts).toHaveBeenCalledWith(
expect.objectContaining({
config: expect.objectContaining({
lockFiles: ['composer.lock'],
}),
}),
);
});

it('for lockFileMaintenance passes proper lockFiles', async () => {
config.upgrades.push({
manager: 'composer',
Expand Down
12 changes: 10 additions & 2 deletions lib/workers/repository/update/branch/get-updated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ export async function getUpdatedPackageFiles(
updatedDeps,
// TODO #22198
newPackageFileContent: packageFile.contents!.toString(),
config,
config: patchConfigForArtifactsUpdate(
config,
manager,
packageFile.path,
),
});
processUpdateArtifactResults(results, updatedArtifacts, artifactErrors);
}
Expand All @@ -329,7 +333,11 @@ export async function getUpdatedPackageFiles(
updatedDeps,
// TODO #22198
newPackageFileContent: packageFile.contents!.toString(),
config,
config: patchConfigForArtifactsUpdate(
config,
manager,
packageFile.path,
),
});
processUpdateArtifactResults(results, updatedArtifacts, artifactErrors);
if (is.nonEmptyArray(results)) {
Expand Down

0 comments on commit a5193da

Please sign in to comment.