Skip to content

Commit 41d3060

Browse files
committed
test: add legacy config properties specific to replicasets
1 parent 4f76a04 commit 41d3060

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

test/runner/config.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ class NativeConfiguration {
1818
parsedURI.options
1919
);
2020

21-
// this.options = environment || {};
22-
// this.host = environment.host || 'localhost';
23-
// this.port = environment.port || 27017;
24-
// this.db = environment.db || 'integration_tests';
25-
// this.setName = environment.setName || 'rs';
26-
27-
// this.topology = environment.topology || this.defaultTopology;
28-
// this.environment = environment;
29-
// if (environment.setName) {
30-
// this.replicasetName = environment.setName || 'rs';
31-
// }
32-
3321
this.mongo = this.require = require('../..');
3422
this.writeConcern = function() {
3523
return { w: 1 };
@@ -52,13 +40,20 @@ class NativeConfiguration {
5240
return this.options.db;
5341
}
5442

43+
// legacy accessors, consider for removal
44+
get replicasetName() {
45+
return this.options.replicaSet;
46+
}
47+
48+
get setName() {
49+
return this.options.replicaSet;
50+
}
51+
5552
usingUnifiedTopology() {
5653
return !!process.env.MONGODB_UNIFIED_TOPOLOGY;
5754
}
5855

5956
newClient(dbOptions, serverOptions) {
60-
// console.trace('newClient');
61-
6257
if (typeof dbOptions === 'string') {
6358
return new MongoClient(
6459
dbOptions,
@@ -133,12 +128,18 @@ class NativeConfiguration {
133128
}
134129

135130
url(username, password) {
131+
const query = {};
132+
if (this.options.replicaSet) {
133+
Object.assign(query, { replicaSet: this.options.replicaSet, auto_reconnect: false });
134+
}
135+
136136
const urlObject = {
137137
protocol: 'mongodb',
138138
slashes: true,
139139
hostname: this.options.host,
140140
port: this.options.port,
141-
pathname: `/${this.options.db}`
141+
pathname: `/${this.options.db}`,
142+
query
142143
};
143144

144145
if (username || password) {

0 commit comments

Comments
 (0)