Skip to content

Commit d66e28a

Browse files
committed
feat(MongoBinaryDownloadUrl): remove function "getMintVersionString"
1 parent 2810078 commit d66e28a

File tree

2 files changed

+55
-90
lines changed

2 files changed

+55
-90
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import getOS, { AnyOS, LinuxOS } from './getos';
2-
import { execSync } from 'child_process';
32
import resolveConfig, { ResolveConfigVariables } from './resolveConfig';
43
import debug from 'debug';
54
import * as semver from 'semver';
@@ -160,8 +159,6 @@ export class MongoBinaryDownloadUrl {
160159
return this.getFedoraVersionString(os);
161160
} else if (regexHelper(/debian/i, os)) {
162161
return this.getDebianVersionString(os);
163-
} else if (regexHelper(/^linux\s?mint\s*$/i, os)) {
164-
return this.getMintVersionString(os);
165162
} else if (regexHelper(/alpine/i, os)) {
166163
console.warn('There is no offical build of MongoDB for Alpine!');
167164
// Match "arch", "archlinux", "manjaro", "manjarolinux", "arco", "arcolinux"
@@ -253,14 +250,6 @@ export class MongoBinaryDownloadUrl {
253250
return name;
254251
}
255252

256-
/**
257-
* Get the version string for Linux Mint
258-
* @param os LinuxOS Object
259-
*/
260-
getMintVersionString(os: LinuxOS): string {
261-
return this.getUbuntuVersionString(os);
262-
}
263-
264253
/**
265254
* Linux Fallback
266255
* @param os LinuxOS Object
@@ -304,7 +293,7 @@ export class MongoBinaryDownloadUrl {
304293
mintToUbuntuRelease[parseInt(os.release.split('.')[0])] || mintToUbuntuRelease[20];
305294
}
306295

307-
if (/^elementary\s?OS\s*$/i.test(os.dist)) {
296+
if (/^elementary\s?os\s*$/i.test(os.dist)) {
308297
const elementaryToUbuntuRelease: Record<number, string> = {
309298
3: '14.04',
310299
4: '16.04',

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

Lines changed: 54 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { LinuxOS } from '../getos';
12
import MongoBinaryDownloadUrl from '../MongoBinaryDownloadUrl';
23
import { defaultValues, ResolveConfigVariables, setDefaultValue } from '../resolveConfig';
34

@@ -203,6 +204,58 @@ describe('MongoBinaryDownloadUrl', () => {
203204
);
204205
});
205206
});
207+
208+
describe('for LinuxMint', () => {
209+
let downloadUrl: MongoBinaryDownloadUrl;
210+
beforeEach(() => {
211+
downloadUrl = new MongoBinaryDownloadUrl({
212+
platform: 'linux',
213+
arch: 'x64',
214+
version: '4.0.20',
215+
os: {
216+
os: 'linux',
217+
dist: 'Linux Mint',
218+
release: '',
219+
id_like: 'ubuntu',
220+
},
221+
});
222+
});
223+
224+
it('should default to Mint Version 20, if version cannot be found in lookup table', async () => {
225+
(downloadUrl.os as LinuxOS).release = '16';
226+
expect(await downloadUrl.getDownloadUrl()).toBe(
227+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.0.20.tgz'
228+
);
229+
});
230+
231+
it('should return a archive name for Linux Mint 17', async () => {
232+
(downloadUrl.os as LinuxOS).release = '17';
233+
expect(await downloadUrl.getDownloadUrl()).toBe(
234+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-4.0.20.tgz'
235+
);
236+
});
237+
238+
it('should return a archive name for Linux Mint 18', async () => {
239+
(downloadUrl.os as LinuxOS).release = '18';
240+
expect(await downloadUrl.getDownloadUrl()).toBe(
241+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.0.20.tgz'
242+
);
243+
});
244+
245+
it('should return a archive name for Linux Mint 19', async () => {
246+
(downloadUrl.os as LinuxOS).release = '19';
247+
expect(await downloadUrl.getDownloadUrl()).toBe(
248+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.0.20.tgz'
249+
);
250+
});
251+
252+
it('should return a archive name for Linux Mint 20', async () => {
253+
(downloadUrl.os as LinuxOS).release = '20';
254+
expect(await downloadUrl.getDownloadUrl()).toBe(
255+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.0.20.tgz'
256+
);
257+
});
258+
});
206259
});
207260

208261
describe('for win32 & windows', () => {
@@ -451,84 +504,7 @@ describe('MongoBinaryDownloadUrl', () => {
451504
});
452505
});
453506

454-
describe('getMintVersionString', () => {
455-
const downloadUrl = new MongoBinaryDownloadUrl({
456-
platform: 'linux',
457-
arch: 'x64',
458-
version: '4.0.20',
459-
});
460-
461-
it('should default to Mint Version 20, if version cannot be found in lookup table', () => {
462-
expect(
463-
downloadUrl.getMintVersionString({
464-
os: 'linux',
465-
dist: 'Linux Mint',
466-
release: '16',
467-
})
468-
).toBe('ubuntu1804');
469-
});
470-
471-
it('should return a archive name for Linux Mint 17', () => {
472-
expect(
473-
downloadUrl.getMintVersionString({
474-
os: 'linux',
475-
dist: 'Linux Mint',
476-
release: '17',
477-
})
478-
).toBe('ubuntu1404');
479-
});
480-
481-
it('should return a archive name for Linux Mint 18', () => {
482-
expect(
483-
downloadUrl.getMintVersionString({
484-
os: 'linux',
485-
dist: 'Linux Mint',
486-
release: '18',
487-
})
488-
).toBe('ubuntu1604');
489-
});
490-
491-
it('should return a archive name for Linux Mint 19', () => {
492-
expect(
493-
downloadUrl.getMintVersionString({
494-
os: 'linux',
495-
dist: 'LinuxMint',
496-
release: '19',
497-
})
498-
).toBe('ubuntu1804');
499-
});
500-
501-
it('should return a archive name for Linux Mint 20', () => {
502-
expect(
503-
downloadUrl.getMintVersionString({
504-
os: 'linux',
505-
dist: 'Linux Mint',
506-
release: '20',
507-
})
508-
).toBe('ubuntu1804');
509-
});
510-
});
511-
512-
it('shouldnt detect linux mint when using peppermint', () => {
513-
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
514-
const downloadUrl = new MongoBinaryDownloadUrl({
515-
platform: 'linux',
516-
arch: 'x64',
517-
version: '3.6.3',
518-
});
519-
520-
expect(
521-
downloadUrl.getLinuxOSVersionString({
522-
os: 'linux',
523-
dist: 'Peppermint',
524-
release: '10',
525-
})
526-
).toBe('');
527-
528-
expect(console.warn).toHaveBeenCalledTimes(1);
529-
});
530-
531-
describe('getLegacyVersionString', () => {
507+
describe('getLegacyVersionString()', () => {
532508
const downloadUrl = new MongoBinaryDownloadUrl({
533509
platform: 'linux',
534510
arch: 'x64',

0 commit comments

Comments
 (0)