Skip to content

Commit 31b4696

Browse files
committed
fix(MongoBinaryDownloadUrl): refactor fedora handling to pass through to rhel
but set the mapping to rhel version first, like linux mint to ubuntu. fixes typegoose#893
1 parent 7a1c0e6 commit 31b4696

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -336,25 +336,31 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
336336
* @param os LinuxOS Object
337337
*/
338338
getFedoraVersionString(os: LinuxOS): string {
339-
let name = 'rhel';
340339
const fedoraVer: number = parseInt(os.release, 10);
341340

341+
const rhelOS: LinuxOS = {
342+
os: 'linux',
343+
dist: 'rhel',
344+
// fallback to 8.0
345+
release: '8.0',
346+
};
347+
342348
// 36 and onwards dont ship with libcrypto.so.1.1 anymore and need to be manually installed ("openssl1.1")
343349
// 34 onward dosnt have "compat-openssl10" anymore, and only build from 4.0.24 are available for "rhel80"
344350
if (fedoraVer >= 34) {
345-
name += '80';
351+
rhelOS.release = '8.0';
346352
}
347353
if (fedoraVer < 34 && fedoraVer >= 19) {
348-
name += '70';
354+
rhelOS.release = '7.0';
349355
}
350356
if (fedoraVer < 19 && fedoraVer >= 12) {
351-
name += '62';
357+
rhelOS.release = '6.2';
352358
}
353359
if (fedoraVer < 12 && fedoraVer >= 6) {
354-
name += '55';
360+
rhelOS.release = '5.5';
355361
}
356362

357-
return name;
363+
return this.getRhelVersionString(rhelOS);
358364
}
359365

360366
/**

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

+16
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,22 @@ describe('MongoBinaryDownloadUrl', () => {
12551255
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-6.0.0.tgz'
12561256
);
12571257
});
1258+
1259+
it('fedora 36 & 7.0.13 x86_64', async () => {
1260+
const du = new MongoBinaryDownloadUrl({
1261+
platform: 'linux',
1262+
arch: 'x64',
1263+
version: '7.0.13',
1264+
os: {
1265+
os: 'linux',
1266+
dist: 'fedora',
1267+
release: '36',
1268+
},
1269+
});
1270+
expect(await du.getDownloadUrl()).toBe(
1271+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel8-7.0.13.tgz'
1272+
);
1273+
});
12581274
});
12591275

12601276
// see https://github.com/typegoose/mongodb-memory-server/issues/527

0 commit comments

Comments
 (0)