Skip to content

Commit 7273a04

Browse files
committed
test(MongoBinaryDownloadUrl): add some rhel tests
1 parent 62d96e6 commit 7273a04

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
297297
* Get the version string for Red Hat Enterprise Linux
298298
* @param os LinuxOS Object
299299
*/
300-
// TODO: add tests for getRhelVersionString
301300
getRhelVersionString(os: LinuxOS): string {
302301
let name = 'rhel';
303302
const { release } = os;

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

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,117 @@ describe('MongoBinaryDownloadUrl', () => {
652652
);
653653
});
654654
});
655+
656+
describe('for rhel', () => {
657+
// These tests are made based on how the current implementation is, no actual rhel testing was done, so the data might be inaccurate
658+
it('rhel 8 & 4.2.0 x86_64', async () => {
659+
const du = new MongoBinaryDownloadUrl({
660+
platform: 'linux',
661+
arch: 'x64',
662+
version: '4.2.0',
663+
os: {
664+
os: 'linux',
665+
dist: 'rhel',
666+
release: '8.2',
667+
},
668+
});
669+
expect(await du.getDownloadUrl()).toBe(
670+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.2.0.tgz'
671+
);
672+
});
673+
674+
it('rhel 8 & 5.0.0 x86_64', async () => {
675+
const du = new MongoBinaryDownloadUrl({
676+
platform: 'linux',
677+
arch: 'x64',
678+
version: '5.0.0',
679+
os: {
680+
os: 'linux',
681+
dist: 'rhel',
682+
release: '8.2',
683+
},
684+
});
685+
expect(await du.getDownloadUrl()).toBe(
686+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-5.0.0.tgz'
687+
);
688+
});
689+
690+
it('rhel 8 & 4.4.2 arm64', async () => {
691+
const du = new MongoBinaryDownloadUrl({
692+
platform: 'linux',
693+
arch: 'arm64',
694+
version: '4.4.2',
695+
os: {
696+
os: 'linux',
697+
dist: 'rhel',
698+
release: '8.2',
699+
},
700+
});
701+
expect(await du.getDownloadUrl()).toBe(
702+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.2.tgz'
703+
);
704+
});
705+
706+
it('rhel 8 & 5.0.0 arm64', async () => {
707+
const du = new MongoBinaryDownloadUrl({
708+
platform: 'linux',
709+
arch: 'arm64',
710+
version: '5.0.0',
711+
os: {
712+
os: 'linux',
713+
dist: 'rhel',
714+
release: '8.2',
715+
},
716+
});
717+
expect(await du.getDownloadUrl()).toBe(
718+
'https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-5.0.0.tgz'
719+
);
720+
});
721+
722+
it('should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError]', async () => {
723+
const du = new MongoBinaryDownloadUrl({
724+
platform: 'linux',
725+
arch: 'arm64',
726+
version: '4.4.2',
727+
os: {
728+
os: 'linux',
729+
dist: 'rhel',
730+
release: '7',
731+
},
732+
});
733+
734+
try {
735+
await du.getDownloadUrl();
736+
fail('Expected to throw a KnownVersionIncompatibilityError');
737+
} catch (err) {
738+
assertIsError(err);
739+
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
740+
expect(err.message).toMatchSnapshot();
741+
}
742+
});
743+
744+
it('should Error when ARM64 and version below 4.4.2 is requested [KnownVersionIncompatibilityError]', async () => {
745+
const du = new MongoBinaryDownloadUrl({
746+
platform: 'linux',
747+
arch: 'arm64',
748+
version: '4.4.0',
749+
os: {
750+
os: 'linux',
751+
dist: 'rhel',
752+
release: '8',
753+
},
754+
});
755+
756+
try {
757+
await du.getDownloadUrl();
758+
fail('Expected to throw a KnownVersionIncompatibilityError');
759+
} catch (err) {
760+
assertIsError(err);
761+
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
762+
expect(err.message).toMatchSnapshot();
763+
}
764+
});
765+
});
655766
});
656767

657768
describe('for win32 & windows', () => {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should thr
1010
Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release"
1111
`;
1212

13+
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError] 1`] = `
14+
"Requested Version \\"4.4.2\\" is not available for \\"Rhel 7\\"! Available Versions: \\">=4.4.2\\"
15+
ARM64(aarch64) support for rhel is only for rhel82 or higher"
16+
`;
17+
18+
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\\""`;
19+
1320
exports[`MongoBinaryDownloadUrl getDownloadUrl() should throw an error if platform is unknown (getArchiveName) 1`] = `"Unknown Platform: \\"unknown\\""`;
1421

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

0 commit comments

Comments
 (0)