Skip to content

Commit 3ae6a45

Browse files
committed
test(MongoBinaryDownloadUrl): add test for "getDownloadUrl" and "DOWNLOAD_MIRROR"
1 parent 1ff0e90 commit 3ae6a45

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,21 @@ describe('MongoBinaryDownloadUrl', () => {
388388
delete process.env[envName(ResolveConfigVariables.DOWNLOAD_URL)];
389389
});
390390

391+
it('should allow mirror overwrite with "DOWNLOAD_MIRROR"', async () => {
392+
const archiveName = 'mongodb-linux-x86_64-4.0.0.tgz';
393+
const mirror = 'https://custom.org';
394+
process.env[envName(ResolveConfigVariables.DOWNLOAD_MIRROR)] = mirror;
395+
396+
const du = new MongoBinaryDownloadUrl({
397+
platform: 'linux',
398+
arch: 'x64',
399+
version: '3.6.3',
400+
});
401+
jest.spyOn(du, 'getArchiveName').mockImplementationOnce(() => Promise.resolve(archiveName));
402+
expect(await du.getDownloadUrl()).toBe(`${mirror}/linux/${archiveName}`);
403+
delete process.env[envName(ResolveConfigVariables.ARCHIVE_NAME)];
404+
});
405+
391406
it('should throw an error if platform is unknown (getArchiveName)', async () => {
392407
// this is to test the default case in "getArchiveName"
393408
const du = new MongoBinaryDownloadUrl({

0 commit comments

Comments
 (0)