Skip to content

Commit 59d3544

Browse files
committed
test(MongoBinaryDownload): add test for "getPath"
1 parent 43b746a commit 59d3544

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownload.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { promises as fspromises } from 'fs';
22
import md5file from 'md5-file';
3+
import { DryMongoBinary } from '../DryMongoBinary';
34
import MongoBinaryDownload from '../MongoBinaryDownload';
45
import { envName, ResolveConfigVariables } from '../resolveConfig';
56
import * as utils from '../utils';
@@ -142,4 +143,25 @@ describe('MongoBinaryDownload', () => {
142143
const result = await du.makeMD5check('', '');
143144
expect(result).toEqual(undefined);
144145
});
146+
147+
it('should return the correct path to binary name (getPath)', async () => {
148+
const downloadDir = '/path/to/downloadDir';
149+
jest.spyOn(DryMongoBinary, 'generateOptions').mockResolvedValue({
150+
arch: 'x64',
151+
version: '4.0.20',
152+
downloadDir: downloadDir,
153+
systemBinary: '',
154+
os: {
155+
os: 'linux',
156+
dist: 'ubuntu',
157+
release: '14',
158+
},
159+
});
160+
161+
const du = new MongoBinaryDownload({ downloadDir });
162+
163+
// @ts-expect-error because "getPath" is "protected"
164+
const path = await du.getPath();
165+
expect(path).toEqual(`${downloadDir}/mongod-x64-ubuntu-4.0.20`);
166+
});
145167
});

0 commit comments

Comments
 (0)