Skip to content

Commit

Permalink
fix(DryMongoBinary::getPath): always absoluteize System_Binary path
Browse files Browse the repository at this point in the history
after the logs so that it is obvious what was provided
  • Loading branch information
hasezoey committed Dec 9, 2024
1 parent 53d00e4 commit c0975c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class DryMongoBinary {
if (!!useOpts.systemBinary) {
log(`locateBinary: env "SYSTEM_BINARY" was provided with value: "${useOpts.systemBinary}"`);

const systemReturn = await this.getSystemPath(useOpts.systemBinary);
const systemReturn = await this.getSystemPath(path.resolve(useOpts.systemBinary));

if (isNullOrUndefined(systemReturn)) {
throw new BinaryNotFoundError(useOpts.systemBinary, ' (systemBinary)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,18 @@ describe('DryBinary', () => {
expect(fspromises.access).toHaveBeenCalled();
});

it('should return SystemBinary with absolute path', async () => {
const mockBinary = 'bin/mongod';
process.env[envName(ResolveConfigVariables.SYSTEM_BINARY)] = mockBinary;
jest.spyOn(fspromises, 'access').mockResolvedValue(void 0);

const returnValue = await binary.DryMongoBinary.locateBinary({ version: '1.1.1' });
expect(returnValue).not.toEqual(mockBinary);
expect(returnValue).toEqual(path.resolve(mockBinary));
expect(binary.DryMongoBinary.binaryCache.size).toBe(0); // system binaries dont get added to the cache
expect(fspromises.access).toHaveBeenCalled();
});

it('should throw an error if SystemBinary was provided, but not found', async () => {
const mockBinary = '/usr/local/bin/mongod';
process.env[envName(ResolveConfigVariables.SYSTEM_BINARY)] = mockBinary;
Expand Down

0 comments on commit c0975c3

Please sign in to comment.