Skip to content

Commit

Permalink
fix: fix binary download on debian testing/unstable (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
orgads committed Aug 17, 2023
1 parent 36bc050 commit 1a8ac8a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
Expand Up @@ -289,7 +289,9 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
throw new UnknownVersionError(this.version);
}

if (release >= 11 || ['unstable', 'testing'].includes(os.release)) {
const isTesting = ['unstable', 'testing', ''].includes(os.release);

if (isTesting || release >= 11) {
// Debian 11 is compatible with the binaries for debian 10
// but does not have binaries for before 5.0.8
// and only set to use "debian10" if the requested version is not a latest version
Expand All @@ -309,10 +311,10 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
name += '71';
}

if (release >= 10) {
if (isTesting || release >= 10) {
if (semver.lt(coercedVersion, '4.2.1') && !testVersionIsLatest(this.version)) {
throw new KnownVersionIncompatibilityError(
`Debian ${release}`,
`Debian ${release || os.release || os.codename}`,
this.version,
'>=4.2.1',
'Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release'
Expand Down
Expand Up @@ -554,6 +554,22 @@ describe('MongoBinaryDownloadUrl', () => {
);
});

it('for debian testing/unstable', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
version: '5.0.9',
os: {
os: 'linux',
dist: 'debian',
release: '',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian11-5.0.9.tgz'
);
});

it('should throw a Error when the provided version could not be coerced [UnknownVersionError]', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
Expand Down Expand Up @@ -635,6 +651,29 @@ describe('MongoBinaryDownloadUrl', () => {
expect(err.message).toMatchSnapshot();
}
});

it('should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError]', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
version: '4.0.25',
os: {
os: 'linux',
dist: 'debian',
codename: 'trixie',
release: '',
},
});

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

// for arch and arch based systems (no specific extra mapping)
Expand Down
Expand Up @@ -10,6 +10,11 @@ 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 debian should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError] 1`] = `
"Requested Version \\"4.0.25\\" is not available for \\"Debian trixie\\"! Available Versions: \\">=4.2.1\\"
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 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\\")"`;

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

0 comments on commit 1a8ac8a

Please sign in to comment.