Skip to content

Commit

Permalink
refactor(MongoMemoryReplSet): remove "async" from "getDbName"
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
removing "async" / modifing return type "Promise<string>" can break code
  • Loading branch information
hasezoey committed Oct 12, 2020
1 parent 9b17925 commit 2775b4f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ export class MongoMemoryReplSet extends EventEmitter {
/**
* Returns database name.
*/
async getDbName(): Promise<string> {
// this function is only async for consistency with MongoMemoryServer
// I don't see much point to either of them being async but don't
// care enough to change it and introduce a breaking change.
getDbName(): string {
return this.opts.replSet.dbName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('multi-member replica set', () => {
// await while all SECONDARIES will be ready
await new Promise((resolve) => setTimeout(resolve, 2000));

const db = await con.db(await replSet.getDbName());
const db = await con.db(replSet.getDbName());
const admin = db.admin();
const status = await admin.replSetGetStatus();
expect(status.members.filter((m: any) => m.stateStr === 'PRIMARY')).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('single server replset', () => {
it('should be able to get dbName', async () => {
const opts: any = { autoStart: false, replSet: { dbName: 'static' } };
const replSet = new MongoMemoryReplSet(opts);
const dbName = await replSet.getDbName();
const dbName = replSet.getDbName();
expect(dbName).toEqual('static');

await replSet.stop();
Expand Down

0 comments on commit 2775b4f

Please sign in to comment.