Skip to content

Commit dbcd00a

Browse files
committed
refactor: change uses of deprecated ".stop(false)" to explicit object
only occurences not changed are tests testing explicitly for "boolean" argument
1 parent 884bda5 commit dbcd00a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
364364

365365
log('ensureAsync chain threw a Error: ', err);
366366

367-
await this.stop(false); // still try to close the instance that was spawned, without cleanup for investigation
367+
await this.stop({ doCleanup: false, force: false }); // still try to close the instance that was spawned, without cleanup for investigation
368368

369369
this.stateChange(MongoMemoryReplSetStates.stopped);
370370

@@ -503,7 +503,9 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
503503
log('stop: state is "stopped", trying to stop / kill anyway');
504504
}
505505

506-
const successfullyStopped = await Promise.all(this.servers.map((s) => s.stop(false)))
506+
const successfullyStopped = await Promise.all(
507+
this.servers.map((s) => s.stop({ doCleanup: false, force: false }))
508+
)
507509
.then(() => {
508510
this.stateChange(MongoMemoryReplSetStates.stopped);
509511

@@ -686,7 +688,7 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
686688
if (!isInMemory) {
687689
log('_initReplSet: closing connection for restart');
688690
await con.close(); // close connection in preparation for "stop"
689-
await this.stop(false); // stop all servers for enabling auth
691+
await this.stop({ doCleanup: false, force: false }); // stop all servers for enabling auth
690692
log('_initReplSet: starting all server again with auth');
691693
await this.initAllServers(); // start all servers again with "auth" enabled
692694

packages/mongodb-memory-server-core/src/MongoMemoryServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
287287

288288
this.debug('_startUpInstance threw a Error: ', err);
289289

290-
await this.stop(false); // still try to close the instance that was spawned, without cleanup for investigation
290+
await this.stop({ doCleanup: false, force: false }); // still try to close the instance that was spawned, without cleanup for investigation
291291

292292
this.stateChange(MongoMemoryServerStates.stopped);
293293

packages/mongodb-memory-server-core/src/__tests__/MongoMemoryServer-restart.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Restart single MongoMemoryServer instance', () => {
3434
await connection.close();
3535
}
3636

37-
await instance.stop(false);
37+
await instance.stop({ doCleanup: false, force: false });
3838
expect(MongoMemoryServer.prototype.cleanup).not.toHaveBeenCalled();
3939

4040
// there is no need to wait here, because a single instance does not need to be forced to the same port

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ describe('MongoMemoryServer', () => {
489489
jest.spyOn(utils, 'isNullOrUndefined');
490490
jest.spyOn(utils, 'assertion');
491491

492-
expect(await mongoServer.stop(false)).toEqual(true);
492+
expect(await mongoServer.stop({ doCleanup: false, force: false })).toEqual(true);
493493
expect(instanceStopSpy).toHaveBeenCalledTimes(1);
494494
expect(utils.isNullOrUndefined).toHaveBeenCalledTimes(1);
495495
expect(utils.assertion).not.toHaveBeenCalled();
@@ -912,12 +912,12 @@ describe('MongoMemoryServer', () => {
912912
it('should start & stop multiple times without creating new instances & directories', async () => {
913913
const mongoServer = await MongoMemoryServer.create();
914914
const dbPath = mongoServer.instanceInfo!.dbPath;
915-
await mongoServer.stop(false);
915+
await mongoServer.stop({ doCleanup: false, force: false });
916916
expect(await utils.statPath(dbPath)).toBeTruthy();
917917
expect(mongoServer.instanceInfo).toBeTruthy();
918918
await mongoServer.start();
919919
expect(mongoServer.instanceInfo!.dbPath).toEqual(dbPath);
920-
await mongoServer.stop(false);
920+
await mongoServer.stop({ doCleanup: false, force: false });
921921
expect(await utils.statPath(dbPath)).toBeTruthy();
922922
expect(mongoServer.instanceInfo).toBeTruthy();
923923

0 commit comments

Comments
 (0)