Skip to content

Commit eef706f

Browse files
committed
fix: remove deprecated boolean cleanup argument (stop / cleanup)
already in 9.x it threw a error, now the error is removed too.
1 parent 1d24e6f commit eef706f

File tree

6 files changed

+0
-96
lines changed

6 files changed

+0
-96
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,6 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
534534
/** Default to cleanup temporary, but not custom dbpaths */
535535
let cleanup: Cleanup = { doCleanup: true, force: false };
536536

537-
// TODO: for next major release (10.0), this should be removed
538-
if (typeof cleanupOptions === 'boolean') {
539-
throw new Error('Unsupported argument type: boolean');
540-
}
541-
542537
// handle the new way of setting what and how to cleanup
543538
if (typeof cleanupOptions === 'object') {
544539
cleanup = cleanupOptions;
@@ -589,11 +584,6 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
589584
/** Default to doing cleanup, but not forcing it */
590585
let cleanup: Cleanup = { doCleanup: true, force: false };
591586

592-
// TODO: for next major release (10.0), this should be removed
593-
if (typeof options === 'boolean') {
594-
throw new Error('Unsupported argument type: boolean');
595-
}
596-
597587
// handle the new way of setting what and how to cleanup
598588
if (typeof options === 'object') {
599589
cleanup = options;

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,6 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
550550
/** Default to cleanup temporary, but not custom dbpaths */
551551
let cleanup: Cleanup = { doCleanup: true, force: false };
552552

553-
// TODO: for next major release (10.0), this should be removed
554-
if (typeof cleanupOptions === 'boolean') {
555-
throw new Error('Unsupported argument type: boolean');
556-
}
557-
558553
// handle the new way of setting what and how to cleanup
559554
if (typeof cleanupOptions === 'object') {
560555
cleanup = cleanupOptions;
@@ -598,11 +593,6 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
598593
/** Default to doing cleanup, but not forcing it */
599594
let cleanup: Cleanup = { doCleanup: true, force: false };
600595

601-
// TODO: for next major release (10.0), this should be removed
602-
if (typeof options === 'boolean') {
603-
throw new Error('Unsupported argument type: boolean');
604-
}
605-
606596
// handle the new way of setting what and how to cleanup
607597
if (typeof options === 'object') {
608598
cleanup = options;

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -590,22 +590,6 @@ describe('MongoMemoryReplSet', () => {
590590
} as utils.Cleanup);
591591
});
592592

593-
it('should not support boolean arguments', async () => {
594-
const replSet = new MongoMemoryReplSet();
595-
596-
try {
597-
await replSet.stop(
598-
// @ts-expect-error Testing a non-existing overload
599-
true
600-
);
601-
fail('Expected to fail');
602-
} catch (err) {
603-
expect(err).toBeInstanceOf(Error);
604-
assertIsError(err);
605-
expect(err.message).toMatchSnapshot();
606-
}
607-
});
608-
609593
it('should call cleanup and pass-through cleanup options', async () => {
610594
const replSet = await MongoMemoryReplSet.create({ replSet: { count: 1 } });
611595

@@ -676,22 +660,6 @@ describe('MongoMemoryReplSet', () => {
676660
} as utils.Cleanup);
677661
});
678662

679-
it('should not support boolean arguments', async () => {
680-
const replSet = new MongoMemoryReplSet();
681-
682-
try {
683-
await replSet.cleanup(
684-
// @ts-expect-error Testing a non-existing overload
685-
true
686-
);
687-
fail('Expected to fail');
688-
} catch (err) {
689-
expect(err).toBeInstanceOf(Error);
690-
assertIsError(err);
691-
expect(err.message).toMatchSnapshot();
692-
}
693-
});
694-
695663
it('should run cleanup with cleanup options and pass-through options to lower', async () => {
696664
const replSet = await MongoMemoryReplSet.create({ replSet: { count: 1 } });
697665

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -628,22 +628,6 @@ describe('MongoMemoryServer', () => {
628628
expect(cleanupSpy).toHaveBeenCalledWith({ doCleanup: true } as utils.Cleanup);
629629
});
630630

631-
it('should not support boolean arguments', async () => {
632-
const mongoServer = new MongoMemoryServer();
633-
634-
try {
635-
await mongoServer.stop(
636-
// @ts-expect-error Testing a non-existing overload
637-
true
638-
);
639-
fail('Expected to fail');
640-
} catch (err) {
641-
expect(err).toBeInstanceOf(Error);
642-
assertIsError(err);
643-
expect(err.message).toMatchSnapshot();
644-
}
645-
});
646-
647631
it('should call cleanup and pass-through cleanup options', async () => {
648632
const mongoServer = new MongoMemoryServer();
649633

@@ -796,22 +780,6 @@ describe('MongoMemoryServer', () => {
796780
expect(mongoServer.instanceInfo).toBeUndefined();
797781
});
798782

799-
it('should not support boolean arguments', async () => {
800-
const mongoServer = new MongoMemoryServer();
801-
802-
try {
803-
await mongoServer.cleanup(
804-
// @ts-expect-error Testing a non-existing overload
805-
true
806-
);
807-
fail('Expected to fail');
808-
} catch (err) {
809-
expect(err).toBeInstanceOf(Error);
810-
assertIsError(err);
811-
expect(err.message).toMatchSnapshot();
812-
}
813-
});
814-
815783
it('should properly cleanup with tmpDir with default no force (new)', async () => {
816784
const mongoServer = await MongoMemoryServer.create();
817785
const dbPath = mongoServer.instanceInfo!.dbPath;

packages/mongodb-memory-server-core/src/__tests__/__snapshots__/MongoMemoryReplSet.test.ts.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
exports[`MongoMemoryReplSet "_waitForPrimary" should throw an error if timeout is reached 1`] = `"{\\"timeout\\":1}"`;
44

5-
exports[`MongoMemoryReplSet .cleanup() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;
6-
7-
exports[`MongoMemoryReplSet .stop() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;
8-
95
exports[`MongoMemoryReplSet getters & setters setter of "replSetOpts" should throw an error if count is 1 or above 1`] = `"ReplSet Count needs to be 1 or higher! (specified count: \\"0\\")"`;
106

117
exports[`MongoMemoryReplSet getters & setters state errors setter of "binaryOpts" should throw an error if state is not "stopped" 1`] = `

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
exports[`MongoMemoryServer "createAuth" should throw an error if called without "this.auth" defined 1`] = `"\\"createAuth\\" got called, but \\"this.auth\\" is undefined!"`;
44

5-
exports[`MongoMemoryServer cleanup() should not support boolean arguments 1`] = `
6-
"Incorrect State for operation: \\"new\\", allowed States: \\"[stopped]\\"
7-
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
8-
https://nodkz.github.io/mongodb-memory-server/docs/guides/migration/migrate7#no-function-other-than-start-create-ensureinstance-will-be-starting-anything"
9-
`;
10-
115
exports[`MongoMemoryServer cleanup() should throw an error if state is not "stopped" 1`] = `
126
"Incorrect State for operation: \\"new\\", allowed States: \\"[stopped]\\"
137
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
@@ -64,5 +58,3 @@ exports[`MongoMemoryServer start() should throw an error if state is not "new" o
6458
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
6559
https://nodkz.github.io/mongodb-memory-server/docs/guides/migration/migrate7#no-function-other-than-start-create-ensureinstance-will-be-starting-anything"
6660
`;
67-
68-
exports[`MongoMemoryServer stop() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;

0 commit comments

Comments
 (0)