Skip to content

Commit

Permalink
test(MongoBinaryDownloadUrl): test the ubuntu fallback default versio…
Browse files Browse the repository at this point in the history
…n if version cannot be parsed
  • Loading branch information
hasezoey committed Jun 8, 2024
1 parent ecc4ffe commit 241742c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\\""`;
Expand Down

0 comments on commit 241742c

Please # to comment.