Skip to content

Commit 666d172

Browse files
committed
test(MongoInstance): test all mongodb LTS versions >=4.0
1 parent ffe2875 commit 666d172

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { assertion, isNullOrUndefined } from '../../util/utils';
55
export = async function globalSetup(): Promise<void> {
66
const defaultVersion = resolveConfig(ResolveConfigVariables.VERSION);
77
assertion(!isNullOrUndefined(defaultVersion), new Error('Default version is not defined'));
8-
const versions = [defaultVersion, '4.0.3'];
8+
const versions = [defaultVersion, '4.0.25', '4.2.14', '4.4.6'];
99
// Ensure all required versions are downloaded for tests
1010
for (const version of versions) {
1111
await MongoBinary.getPath({ version });

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

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,36 @@ describe('MongodbInstance', () => {
174174
expect(dbUtil.isAlive(killerPid)).toBeFalsy();
175175
});
176176

177-
it('should work with mongodb 4.0.3', async () => {
178-
const gotPort = await getPort({ port: 27445 });
179-
const mongod = await MongodbInstance.create({
180-
instance: { port: gotPort, dbPath: tmpDir.name },
181-
binary: { version: '4.0.3' },
177+
describe('should work with mongodb LTS releases', () => {
178+
it('should work with mongodb 4.0', async () => {
179+
const gotPort = await getPort({ port: 27445 });
180+
const mongod = await MongodbInstance.create({
181+
instance: { port: gotPort, dbPath: tmpDir.name },
182+
binary: { version: '4.0.25' }, // explicit version instead of default to not mess it up later
183+
});
184+
expect(mongod.mongodProcess!.pid).toBeGreaterThan(0);
185+
await mongod.stop();
186+
});
187+
188+
it('should work with mongodb 4.2', async () => {
189+
const gotPort = await getPort({ port: 27445 });
190+
const mongod = await MongodbInstance.create({
191+
instance: { port: gotPort, dbPath: tmpDir.name },
192+
binary: { version: '4.2.14' },
193+
});
194+
expect(mongod.mongodProcess!.pid).toBeGreaterThan(0);
195+
await mongod.stop();
196+
});
197+
198+
it('should work with mongodb 4.4', async () => {
199+
const gotPort = await getPort({ port: 27445 });
200+
const mongod = await MongodbInstance.create({
201+
instance: { port: gotPort, dbPath: tmpDir.name },
202+
binary: { version: '4.4.6' },
203+
});
204+
expect(mongod.mongodProcess!.pid).toBeGreaterThan(0);
205+
await mongod.stop();
182206
});
183-
expect(mongod.mongodProcess!.pid).toBeGreaterThan(0);
184-
await mongod.stop();
185207
});
186208

187209
it('"kill" should not call "killProcess" if no childProcesses are not running', async () => {

0 commit comments

Comments
 (0)