Skip to content

Commit 2810078

Browse files
committed
test(MongoBinaryDownloadUrl): change organization of tests in "getDownloadUrl()"
1 parent fc08c25 commit 2810078

File tree

1 file changed

+147
-145
lines changed

1 file changed

+147
-145
lines changed

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

Lines changed: 147 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,156 @@ describe('MongoBinaryDownloadUrl', () => {
5353
});
5454
});
5555

56-
it('for ubuntu', async () => {
57-
const du = new MongoBinaryDownloadUrl({
58-
platform: 'linux',
59-
arch: 'x64',
60-
version: '3.6.3',
61-
os: {
62-
os: 'linux',
63-
dist: 'Ubuntu Linux',
64-
release: '14.04',
65-
},
56+
describe('for linux', () => {
57+
it('for ubuntu', async () => {
58+
const du = new MongoBinaryDownloadUrl({
59+
platform: 'linux',
60+
arch: 'x64',
61+
version: '3.6.3',
62+
os: {
63+
os: 'linux',
64+
dist: 'Ubuntu Linux',
65+
release: '14.04',
66+
},
67+
});
68+
expect(await du.getDownloadUrl()).toBe(
69+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.6.3.tgz'
70+
);
6671
});
67-
expect(await du.getDownloadUrl()).toBe(
68-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.6.3.tgz'
69-
);
70-
});
7172

72-
it('for debian', async () => {
73-
const du = new MongoBinaryDownloadUrl({
74-
platform: 'linux',
75-
arch: 'x64',
76-
version: '3.6.3',
77-
os: {
78-
os: 'linux',
79-
dist: 'debian',
80-
release: '8.1',
81-
},
73+
it('for debian', async () => {
74+
const du = new MongoBinaryDownloadUrl({
75+
platform: 'linux',
76+
arch: 'x64',
77+
version: '3.6.3',
78+
os: {
79+
os: 'linux',
80+
dist: 'debian',
81+
release: '8.1',
82+
},
83+
});
84+
expect(await du.getDownloadUrl()).toBe(
85+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-3.6.3.tgz'
86+
);
87+
});
88+
89+
it('fallback', async () => {
90+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
91+
92+
const du = new MongoBinaryDownloadUrl({
93+
platform: 'linux',
94+
arch: 'x64',
95+
version: '3.6.3',
96+
os: {
97+
os: 'linux',
98+
dist: 'Gentoo Linux',
99+
release: '',
100+
},
101+
});
102+
103+
expect(await du.getDownloadUrl()).toBe(
104+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz'
105+
);
106+
expect(console.warn).toHaveBeenCalledTimes(1);
107+
});
108+
109+
it('for manjaro', async () => {
110+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
111+
112+
const du = new MongoBinaryDownloadUrl({
113+
platform: 'linux',
114+
arch: 'x64',
115+
version: '4.4.2',
116+
os: {
117+
os: 'linux',
118+
dist: 'ManjaroLinux',
119+
release: '20.2',
120+
id_like: 'arch',
121+
},
122+
});
123+
expect(await du.getDownloadUrl()).toBe(
124+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
125+
);
126+
expect(console.warn).toHaveBeenCalledTimes(1);
127+
});
128+
129+
it('for arch', async () => {
130+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
131+
132+
const du = new MongoBinaryDownloadUrl({
133+
platform: 'linux',
134+
arch: 'x64',
135+
version: '4.4.2',
136+
os: {
137+
os: 'linux',
138+
dist: 'Arch',
139+
release: 'rolling',
140+
id_like: 'arch',
141+
},
142+
});
143+
expect(await du.getDownloadUrl()).toBe(
144+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
145+
);
146+
expect(console.warn).toHaveBeenCalledTimes(1);
147+
});
148+
149+
it('for unpopular arch', async () => {
150+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
151+
152+
const du = new MongoBinaryDownloadUrl({
153+
platform: 'linux',
154+
arch: 'x64',
155+
version: '4.4.2',
156+
os: {
157+
os: 'linux',
158+
dist: 'ArchStrike',
159+
release: 'rolling',
160+
id_like: 'arch',
161+
},
162+
});
163+
expect(await du.getDownloadUrl()).toBe(
164+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
165+
);
166+
expect(console.warn).toHaveBeenCalledTimes(1);
167+
});
168+
169+
describe('for elementary', () => {
170+
it('should return a archive name for elementary 0.3', async () => {
171+
const du = new MongoBinaryDownloadUrl({
172+
platform: 'linux',
173+
arch: 'x64',
174+
version: '4.4.1',
175+
os: {
176+
os: 'linux',
177+
dist: 'elementary OS',
178+
release: '0.3',
179+
id_like: 'ubuntu',
180+
},
181+
});
182+
183+
expect(await du.getDownloadUrl()).toBe(
184+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-4.4.1.tgz'
185+
);
186+
});
187+
188+
it('should return a archive name for elementary 5', async () => {
189+
const du = new MongoBinaryDownloadUrl({
190+
platform: 'linux',
191+
arch: 'x64',
192+
version: '4.4.1',
193+
os: {
194+
os: 'linux',
195+
dist: 'elementary OS',
196+
release: '5.1',
197+
id_like: 'ubuntu',
198+
},
199+
});
200+
201+
expect(await du.getDownloadUrl()).toBe(
202+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.4.1.tgz'
203+
);
204+
});
82205
});
83-
expect(await du.getDownloadUrl()).toBe(
84-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-3.6.3.tgz'
85-
);
86206
});
87207

88208
describe('for win32 & windows', () => {
@@ -142,26 +262,6 @@ describe('MongoBinaryDownloadUrl', () => {
142262
});
143263
});
144264

145-
it('fallback', async () => {
146-
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
147-
148-
const du = new MongoBinaryDownloadUrl({
149-
platform: 'linux',
150-
arch: 'x64',
151-
version: '3.6.3',
152-
os: {
153-
os: 'linux',
154-
dist: 'Gentoo Linux',
155-
release: '',
156-
},
157-
});
158-
159-
expect(await du.getDownloadUrl()).toBe(
160-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz'
161-
);
162-
expect(console.warn).toHaveBeenCalledTimes(1);
163-
});
164-
165265
it('should allow overwrite with "ARCHIVE_NAME"', async () => {
166266
const archiveName = 'mongodb-linux-x86_64-4.0.0.tgz';
167267
setDefaultValue(ResolveConfigVariables.ARCHIVE_NAME, archiveName);
@@ -203,104 +303,6 @@ describe('MongoBinaryDownloadUrl', () => {
203303
expect(err.message).toEqual('Unknown Platform "unknown"');
204304
}
205305
});
206-
207-
it('for manjaro', async () => {
208-
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
209-
210-
const du = new MongoBinaryDownloadUrl({
211-
platform: 'linux',
212-
arch: 'x64',
213-
version: '4.4.2',
214-
os: {
215-
os: 'linux',
216-
dist: 'ManjaroLinux',
217-
release: '20.2',
218-
id_like: 'arch',
219-
},
220-
});
221-
expect(await du.getDownloadUrl()).toBe(
222-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
223-
);
224-
expect(console.warn).toHaveBeenCalledTimes(1);
225-
});
226-
227-
it('for arch', async () => {
228-
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
229-
230-
const du = new MongoBinaryDownloadUrl({
231-
platform: 'linux',
232-
arch: 'x64',
233-
version: '4.4.2',
234-
os: {
235-
os: 'linux',
236-
dist: 'Arch',
237-
release: 'rolling',
238-
id_like: 'arch',
239-
},
240-
});
241-
expect(await du.getDownloadUrl()).toBe(
242-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
243-
);
244-
expect(console.warn).toHaveBeenCalledTimes(1);
245-
});
246-
247-
it('for unpopular arch', async () => {
248-
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
249-
250-
const du = new MongoBinaryDownloadUrl({
251-
platform: 'linux',
252-
arch: 'x64',
253-
version: '4.4.2',
254-
os: {
255-
os: 'linux',
256-
dist: 'ArchStrike',
257-
release: 'rolling',
258-
id_like: 'arch',
259-
},
260-
});
261-
expect(await du.getDownloadUrl()).toBe(
262-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.2.tgz'
263-
);
264-
expect(console.warn).toHaveBeenCalledTimes(1);
265-
});
266-
267-
describe('for elementary', () => {
268-
it('should return a archive name for elementary 0.3', async () => {
269-
const du = new MongoBinaryDownloadUrl({
270-
platform: 'linux',
271-
arch: 'x64',
272-
version: '4.4.1',
273-
os: {
274-
os: 'linux',
275-
dist: 'elementary OS',
276-
release: '0.3',
277-
id_like: 'ubuntu',
278-
},
279-
});
280-
281-
expect(await du.getDownloadUrl()).toBe(
282-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-4.4.1.tgz'
283-
);
284-
});
285-
286-
it('should return a archive name for elementary 5', async () => {
287-
const du = new MongoBinaryDownloadUrl({
288-
platform: 'linux',
289-
arch: 'x64',
290-
version: '4.4.1',
291-
os: {
292-
os: 'linux',
293-
dist: 'elementary OS',
294-
release: '5.1',
295-
id_like: 'ubuntu',
296-
},
297-
});
298-
299-
expect(await du.getDownloadUrl()).toBe(
300-
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.4.1.tgz'
301-
);
302-
});
303-
});
304306
});
305307

306308
describe('getUbuntuVersionString()', () => {

0 commit comments

Comments
 (0)