Skip to content

Commit

Permalink
test(MongoBinaryDownloadUrl): add some rhel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Jul 24, 2022
1 parent 62d96e6 commit 7273a04
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
* Get the version string for Red Hat Enterprise Linux
* @param os LinuxOS Object
*/
// TODO: add tests for getRhelVersionString
getRhelVersionString(os: LinuxOS): string {
let name = 'rhel';
const { release } = os;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,117 @@ describe('MongoBinaryDownloadUrl', () => {
);
});
});

describe('for rhel', () => {
// These tests are made based on how the current implementation is, no actual rhel testing was done, so the data might be inaccurate
it('rhel 8 & 4.2.0 x86_64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
version: '4.2.0',
os: {
os: 'linux',
dist: 'rhel',
release: '8.2',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.2.0.tgz'
);
});

it('rhel 8 & 5.0.0 x86_64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
version: '5.0.0',
os: {
os: 'linux',
dist: 'rhel',
release: '8.2',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-5.0.0.tgz'
);
});

it('rhel 8 & 4.4.2 arm64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'arm64',
version: '4.4.2',
os: {
os: 'linux',
dist: 'rhel',
release: '8.2',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.2.tgz'
);
});

it('rhel 8 & 5.0.0 arm64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'arm64',
version: '5.0.0',
os: {
os: 'linux',
dist: 'rhel',
release: '8.2',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-5.0.0.tgz'
);
});

it('should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError]', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'arm64',
version: '4.4.2',
os: {
os: 'linux',
dist: 'rhel',
release: '7',
},
});

try {
await du.getDownloadUrl();
fail('Expected to throw a KnownVersionIncompatibilityError');
} catch (err) {
assertIsError(err);
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
expect(err.message).toMatchSnapshot();
}
});

it('should Error when ARM64 and version below 4.4.2 is requested [KnownVersionIncompatibilityError]', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'arm64',
version: '4.4.0',
os: {
os: 'linux',
dist: 'rhel',
release: '8',
},
});

try {
await du.getDownloadUrl();
fail('Expected to throw a KnownVersionIncompatibilityError');
} catch (err) {
assertIsError(err);
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
expect(err.message).toMatchSnapshot();
}
});
});
});

describe('for win32 & windows', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should thr
Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release"
`;

exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError] 1`] = `
"Requested Version \\"4.4.2\\" is not available for \\"Rhel 7\\"! Available Versions: \\">=4.4.2\\"
ARM64(aarch64) support for rhel is only for rhel82 or higher"
`;

exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and version below 4.4.2 is requested [KnownVersionIncompatibilityError] 1`] = `"Requested Version \\"4.4.0\\" is not available for \\"Rhel 8\\"! Available Versions: \\">=4.4.2\\""`;

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

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

0 comments on commit 7273a04

Please sign in to comment.