Skip to content

Commit b088af2

Browse files
committed
feat(MongoMemoryReplSet): deprecate "getConnectionString"
1 parent 332a18a commit b088af2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from './types';
1313
import debug from 'debug';
1414
import { MongoError } from 'mongodb';
15+
import { deprecate } from 'util';
1516

1617
const log = debug('MongoMS:MongoMemoryReplSet');
1718

@@ -146,9 +147,14 @@ export default class MongoMemoryReplSet extends EventEmitter {
146147
/**
147148
* Get the Connection String for mongodb to connect
148149
* @param otherDb use a different database than what was set on creation?
150+
* @deprecated
149151
*/
150152
async getConnectionString(otherDb?: string | boolean): Promise<string> {
151-
return this.getUri(otherDb);
153+
return deprecate(
154+
this.getUri,
155+
'"MongoMemoryReplSet.getConnectionString" is deprecated, use ".getUri"',
156+
'MDEP001'
157+
).call(this, otherDb);
152158
}
153159

154160
/**

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ describe('single server replset', () => {
1717
const replSet = new MongoMemoryReplSet({});
1818
await replSet.waitUntilRunning();
1919
const uri = await replSet.getUri('other');
20-
const str = await replSet.getConnectionString('other');
2120
expect(uri.split(',').length).toEqual(1);
2221
expect(uri.includes('/other')).toBeTruthy();
2322
expect(uri.includes('replicaSet=testset')).toBeTruthy();
24-
expect(str).toEqual(uri);
2523

2624
await replSet.stop();
2725
});

0 commit comments

Comments
 (0)