Skip to content
Snippets Groups Projects
Unverified Commit fdb6104b authored by Kevin James's avatar Kevin James Committed by GitHub
Browse files

fix(manager/mix): support lockfiles in subdirs (#10689)

parent daff0f2e
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,7 @@ describe(getName(), () => {
jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce();
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
fs.readLocalFile.mockResolvedValueOnce('Old mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
const execSnapshots = mockExecAll(exec);
fs.readLocalFile.mockResolvedValueOnce('New mix.lock');
expect(
......@@ -96,8 +97,24 @@ describe(getName(), () => {
expect(execSnapshots).toMatchSnapshot();
});
it('returns updated mix.lock in subdir', async () => {
setAdminConfig({ ...adminConfig, binarySource: 'docker' });
fs.getSiblingFileName.mockReturnValueOnce('subdir/mix.lock');
mockExecAll(exec);
expect(
await updateArtifacts({
packageFileName: 'subdir/mix.exs',
updatedDeps: [{ depName: 'plug' }],
newPackageFileContent: '{}',
config,
})
).toBeNull();
expect(fs.readLocalFile).toHaveBeenCalledWith('subdir/mix.lock', 'utf8');
});
it('catches write errors', async () => {
fs.readLocalFile.mockResolvedValueOnce('Current mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
fs.writeLocalFile.mockImplementationOnce(() => {
throw new Error('not found');
});
......@@ -113,6 +130,7 @@ describe(getName(), () => {
it('catches exec errors', async () => {
fs.readLocalFile.mockResolvedValueOnce('Current mix.lock');
fs.getSiblingFileName.mockReturnValueOnce('mix.lock');
exec.mockImplementationOnce(() => {
throw new Error('exec-error');
});
......
......@@ -2,7 +2,11 @@ import { quote } from 'shlex';
import { TEMPORARY_ERROR } from '../../constants/error-messages';
import { logger } from '../../logger';
import { ExecOptions, exec } from '../../util/exec';
import { readLocalFile, writeLocalFile } from '../../util/fs';
import {
getSiblingFileName,
readLocalFile,
writeLocalFile,
} from '../../util/fs';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
export async function updateArtifacts({
......@@ -16,7 +20,7 @@ export async function updateArtifacts({
return null;
}
const lockFileName = 'mix.lock';
const lockFileName = getSiblingFileName(packageFileName, 'mix.lock');
try {
await writeLocalFile(packageFileName, newPackageFileContent);
} catch (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment