diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts index 612b1e3d3..b6a049d60 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts +++ b/packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts @@ -145,6 +145,26 @@ describe('MongoBinaryDownloadUrl', () => { describe('for linux', () => { describe('for ubuntu', () => { + it('should default to Ubuntu 22.04, if version cannot be parsed', async () => { + const spy = jest.spyOn(console, 'warn').mockImplementationOnce(() => void 0); + // TODO: try to keep this up-to-date to the latest mongodb supported ubuntu version + const du = new MongoBinaryDownloadUrl({ + platform: 'linux', + arch: 'x64', + version: '7.0.4', + os: { + os: 'linux', + dist: 'ubuntu', + release: '', + }, + }); + expect(await du.getDownloadUrl()).toBe( + 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.4.tgz' + ); + expect(console.warn).toHaveBeenCalledTimes(1); + expect(spy.mock.calls).toMatchSnapshot(); + }); + it('for ubuntu 14.04 for 3.6', async () => { const du = new MongoBinaryDownloadUrl({ platform: 'linux', diff --git a/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap b/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap index 2c1bce9ba..9d33b3ce4 100644 --- a/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap +++ b/packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap @@ -36,6 +36,14 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error 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\\")"`; +exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for ubuntu should default to Ubuntu 22.04, if version cannot be parsed 1`] = ` +Array [ + Array [ + "Could not parse ubuntu year from \\"\\", using default", + ], +] +`; + 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\\")"`; exports[`MongoBinaryDownloadUrl getDownloadUrl() should throw an error if platform is unknown (getArchiveName) 1`] = `"Unknown Platform: \\"unknown\\""`;