Skip to content

Commit

Permalink
fix: remove deprecated boolean cleanup argument (stop / cleanup)
Browse files Browse the repository at this point in the history
already in 9.x it threw a error, now the error is removed too.
  • Loading branch information
hasezoey committed Jun 8, 2024
1 parent 1d24e6f commit eef706f
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 96 deletions.
10 changes: 0 additions & 10 deletions packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,6 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
/** Default to cleanup temporary, but not custom dbpaths */
let cleanup: Cleanup = { doCleanup: true, force: false };

// TODO: for next major release (10.0), this should be removed
if (typeof cleanupOptions === 'boolean') {
throw new Error('Unsupported argument type: boolean');
}

// handle the new way of setting what and how to cleanup
if (typeof cleanupOptions === 'object') {
cleanup = cleanupOptions;
Expand Down Expand Up @@ -589,11 +584,6 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
/** Default to doing cleanup, but not forcing it */
let cleanup: Cleanup = { doCleanup: true, force: false };

// TODO: for next major release (10.0), this should be removed
if (typeof options === 'boolean') {
throw new Error('Unsupported argument type: boolean');
}

// handle the new way of setting what and how to cleanup
if (typeof options === 'object') {
cleanup = options;
Expand Down
10 changes: 0 additions & 10 deletions packages/mongodb-memory-server-core/src/MongoMemoryServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,6 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
/** Default to cleanup temporary, but not custom dbpaths */
let cleanup: Cleanup = { doCleanup: true, force: false };

// TODO: for next major release (10.0), this should be removed
if (typeof cleanupOptions === 'boolean') {
throw new Error('Unsupported argument type: boolean');
}

// handle the new way of setting what and how to cleanup
if (typeof cleanupOptions === 'object') {
cleanup = cleanupOptions;
Expand Down Expand Up @@ -598,11 +593,6 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
/** Default to doing cleanup, but not forcing it */
let cleanup: Cleanup = { doCleanup: true, force: false };

// TODO: for next major release (10.0), this should be removed
if (typeof options === 'boolean') {
throw new Error('Unsupported argument type: boolean');
}

// handle the new way of setting what and how to cleanup
if (typeof options === 'object') {
cleanup = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,22 +590,6 @@ describe('MongoMemoryReplSet', () => {
} as utils.Cleanup);
});

it('should not support boolean arguments', async () => {
const replSet = new MongoMemoryReplSet();

try {
await replSet.stop(
// @ts-expect-error Testing a non-existing overload
true
);
fail('Expected to fail');
} catch (err) {
expect(err).toBeInstanceOf(Error);
assertIsError(err);
expect(err.message).toMatchSnapshot();
}
});

it('should call cleanup and pass-through cleanup options', async () => {
const replSet = await MongoMemoryReplSet.create({ replSet: { count: 1 } });

Expand Down Expand Up @@ -676,22 +660,6 @@ describe('MongoMemoryReplSet', () => {
} as utils.Cleanup);
});

it('should not support boolean arguments', async () => {
const replSet = new MongoMemoryReplSet();

try {
await replSet.cleanup(
// @ts-expect-error Testing a non-existing overload
true
);
fail('Expected to fail');
} catch (err) {
expect(err).toBeInstanceOf(Error);
assertIsError(err);
expect(err.message).toMatchSnapshot();
}
});

it('should run cleanup with cleanup options and pass-through options to lower', async () => {
const replSet = await MongoMemoryReplSet.create({ replSet: { count: 1 } });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,22 +628,6 @@ describe('MongoMemoryServer', () => {
expect(cleanupSpy).toHaveBeenCalledWith({ doCleanup: true } as utils.Cleanup);
});

it('should not support boolean arguments', async () => {
const mongoServer = new MongoMemoryServer();

try {
await mongoServer.stop(
// @ts-expect-error Testing a non-existing overload
true
);
fail('Expected to fail');
} catch (err) {
expect(err).toBeInstanceOf(Error);
assertIsError(err);
expect(err.message).toMatchSnapshot();
}
});

it('should call cleanup and pass-through cleanup options', async () => {
const mongoServer = new MongoMemoryServer();

Expand Down Expand Up @@ -796,22 +780,6 @@ describe('MongoMemoryServer', () => {
expect(mongoServer.instanceInfo).toBeUndefined();
});

it('should not support boolean arguments', async () => {
const mongoServer = new MongoMemoryServer();

try {
await mongoServer.cleanup(
// @ts-expect-error Testing a non-existing overload
true
);
fail('Expected to fail');
} catch (err) {
expect(err).toBeInstanceOf(Error);
assertIsError(err);
expect(err.message).toMatchSnapshot();
}
});

it('should properly cleanup with tmpDir with default no force (new)', async () => {
const mongoServer = await MongoMemoryServer.create();
const dbPath = mongoServer.instanceInfo!.dbPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

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

exports[`MongoMemoryReplSet .cleanup() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;

exports[`MongoMemoryReplSet .stop() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;

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\\")"`;

exports[`MongoMemoryReplSet getters & setters state errors setter of "binaryOpts" should throw an error if state is not "stopped" 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

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

exports[`MongoMemoryServer cleanup() should not support boolean arguments 1`] = `
"Incorrect State for operation: \\"new\\", allowed States: \\"[stopped]\\"
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
https://nodkz.github.io/mongodb-memory-server/docs/guides/migration/migrate7#no-function-other-than-start-create-ensureinstance-will-be-starting-anything"
`;

exports[`MongoMemoryServer cleanup() should throw an error if state is not "stopped" 1`] = `
"Incorrect State for operation: \\"new\\", allowed States: \\"[stopped]\\"
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
Expand Down Expand Up @@ -64,5 +58,3 @@ exports[`MongoMemoryServer start() should throw an error if state is not "new" o
This may be because of using a v6.x way of calling functions, look at the following guide if anything applies:
https://nodkz.github.io/mongodb-memory-server/docs/guides/migration/migrate7#no-function-other-than-start-create-ensureinstance-will-be-starting-anything"
`;

exports[`MongoMemoryServer stop() should not support boolean arguments 1`] = `"Unsupported argument type: boolean"`;

0 comments on commit eef706f

Please sign in to comment.