Skip to content

Commit 9d5bdbf

Browse files
authored
fix(DryMongoBinary::parseArchiveNameRegex): change regex to include "macos" (#562)
1 parent 88346df commit 9d5bdbf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/mongodb-memory-server-core/src/util/DryMongoBinary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class DryMongoBinary {
160160
log(`parseArchiveNameRegex (input: "${input}")`);
161161

162162
const archiveMatches =
163-
/mongodb-(?<platform>linux|win32|osx)(?:-ssl-|-)(?<arch>\w{4,})(?:-(?<dist>\w+)|)(?:-ssl-|-)(?:v|)(?<version>[\d.]+(?:-latest|))\./gim.exec(
163+
/mongodb-(?<platform>linux|win32|osx|macos)(?:-ssl-|-)(?<arch>\w{4,})(?:-(?<dist>\w+)|)(?:-ssl-|-)(?:v|)(?<version>[\d.]+(?:-latest|))\./gim.exec(
164164
input
165165
);
166166

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,33 @@ describe('DryBinary', () => {
607607
});
608608
});
609609

610+
it('should parse and overwrite input options MACOS with macos in archive name', async () => {
611+
const input = 'http://downloads.mongodb.org/osx/mongodb-macos-x86_64-5.0.3.tgz';
612+
// The following options are made different to check that the function actually changes them
613+
const customos: OtherOS = {
614+
os: 'win32',
615+
};
616+
const origOptions: Required<binary.DryMongoBinaryOptions> = {
617+
version: '5.0.3',
618+
arch: 'arm64',
619+
os: customos,
620+
downloadDir: '/path/to/somewhere',
621+
systemBinary: '',
622+
};
623+
624+
const output = binary.DryMongoBinary.parseArchiveNameRegex(input, origOptions);
625+
626+
expect(output).toStrictEqual<binary.DryMongoBinaryOptions>({
627+
version: '5.0.3',
628+
arch: 'x86_64',
629+
downloadDir: origOptions.downloadDir,
630+
systemBinary: '',
631+
os: {
632+
os: 'macos',
633+
},
634+
});
635+
});
636+
610637
it('should parse and overwrite input options WINDOWS', async () => {
611638
const input =
612639
'https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.25.zip';

0 commit comments

Comments
 (0)