Skip to content

Commit 1a8ac8a

Browse files
authored
fix: fix binary download on debian testing/unstable (#787)
VERSION_ID was removed. See https://tracker.debian.org/news/1433360/accepted-base-files-13-source-into-unstable/ and a similar bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008735
1 parent 36bc050 commit 1a8ac8a

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
289289
throw new UnknownVersionError(this.version);
290290
}
291291

292-
if (release >= 11 || ['unstable', 'testing'].includes(os.release)) {
292+
const isTesting = ['unstable', 'testing', ''].includes(os.release);
293+
294+
if (isTesting || release >= 11) {
293295
// Debian 11 is compatible with the binaries for debian 10
294296
// but does not have binaries for before 5.0.8
295297
// and only set to use "debian10" if the requested version is not a latest version
@@ -309,10 +311,10 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
309311
name += '71';
310312
}
311313

312-
if (release >= 10) {
314+
if (isTesting || release >= 10) {
313315
if (semver.lt(coercedVersion, '4.2.1') && !testVersionIsLatest(this.version)) {
314316
throw new KnownVersionIncompatibilityError(
315-
`Debian ${release}`,
317+
`Debian ${release || os.release || os.codename}`,
316318
this.version,
317319
'>=4.2.1',
318320
'Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release'

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,22 @@ describe('MongoBinaryDownloadUrl', () => {
554554
);
555555
});
556556

557+
it('for debian testing/unstable', async () => {
558+
const du = new MongoBinaryDownloadUrl({
559+
platform: 'linux',
560+
arch: 'x64',
561+
version: '5.0.9',
562+
os: {
563+
os: 'linux',
564+
dist: 'debian',
565+
release: '',
566+
},
567+
});
568+
expect(await du.getDownloadUrl()).toBe(
569+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian11-5.0.9.tgz'
570+
);
571+
});
572+
557573
it('should throw a Error when the provided version could not be coerced [UnknownVersionError]', async () => {
558574
const du = new MongoBinaryDownloadUrl({
559575
platform: 'linux',
@@ -635,6 +651,29 @@ describe('MongoBinaryDownloadUrl', () => {
635651
expect(err.message).toMatchSnapshot();
636652
}
637653
});
654+
655+
it('should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError]', async () => {
656+
const du = new MongoBinaryDownloadUrl({
657+
platform: 'linux',
658+
arch: 'x64',
659+
version: '4.0.25',
660+
os: {
661+
os: 'linux',
662+
dist: 'debian',
663+
codename: 'trixie',
664+
release: '',
665+
},
666+
});
667+
668+
try {
669+
await du.getDownloadUrl();
670+
fail('Expected to throw a KnownVersionIncompatibilityError');
671+
} catch (err) {
672+
assertIsError(err);
673+
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
674+
expect(err.message).toMatchSnapshot();
675+
}
676+
});
638677
});
639678

640679
// for arch and arch based systems (no specific extra mapping)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ 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 debian should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError] 1`] = `
14+
"Requested Version \\"4.0.25\\" is not available for \\"Debian trixie\\"! Available Versions: \\">=4.2.1\\"
15+
Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release"
16+
`;
17+
1318
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not corece VERSION to a semver version (version: \\"vvv\\")"`;
1419

1520
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError] 1`] = `

0 commit comments

Comments
 (0)