Skip to content

Commit 241742c

Browse files
committed
test(MongoBinaryDownloadUrl): test the ubuntu fallback default version if version cannot be parsed
1 parent ecc4ffe commit 241742c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,26 @@ describe('MongoBinaryDownloadUrl', () => {
145145

146146
describe('for linux', () => {
147147
describe('for ubuntu', () => {
148+
it('should default to Ubuntu 22.04, if version cannot be parsed', async () => {
149+
const spy = jest.spyOn(console, 'warn').mockImplementationOnce(() => void 0);
150+
// TODO: try to keep this up-to-date to the latest mongodb supported ubuntu version
151+
const du = new MongoBinaryDownloadUrl({
152+
platform: 'linux',
153+
arch: 'x64',
154+
version: '7.0.4',
155+
os: {
156+
os: 'linux',
157+
dist: 'ubuntu',
158+
release: '',
159+
},
160+
});
161+
expect(await du.getDownloadUrl()).toBe(
162+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.4.tgz'
163+
);
164+
expect(console.warn).toHaveBeenCalledTimes(1);
165+
expect(spy.mock.calls).toMatchSnapshot();
166+
});
167+
148168
it('for ubuntu 14.04 for 3.6', async () => {
149169
const du = new MongoBinaryDownloadUrl({
150170
platform: 'linux',

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error
3636

3737
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not coerce VERSION to a semver version (version: \\"vvv\\")"`;
3838

39+
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for ubuntu should default to Ubuntu 22.04, if version cannot be parsed 1`] = `
40+
Array [
41+
Array [
42+
"Could not parse ubuntu year from \\"\\", using default",
43+
],
44+
]
45+
`;
46+
3947
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for ubuntu should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not coerce VERSION to a semver version (version: \\"vvv\\")"`;
4048

4149
exports[`MongoBinaryDownloadUrl getDownloadUrl() should throw an error if platform is unknown (getArchiveName) 1`] = `"Unknown Platform: \\"unknown\\""`;

0 commit comments

Comments
 (0)