diff --git a/src/operations/map_reduce.ts b/src/operations/map_reduce.ts index d89bb5202f4..5786b9a6a4c 100644 --- a/src/operations/map_reduce.ts +++ b/src/operations/map_reduce.ts @@ -8,7 +8,7 @@ import { Callback, maxWireVersion } from '../utils'; -import { ReadPreference, ReadPreferenceMode } from '../read_preference'; +import { ReadPreference } from '../read_preference'; import { CommandOperation, CommandOperationOptions } from './command'; import type { Server } from '../sdam/server'; import type { Collection } from '../collection'; diff --git a/test/functional/apm.test.js b/test/functional/apm.test.js index bf0c7907ee1..5f5899cc372 100644 --- a/test/functional/apm.test.js +++ b/test/functional/apm.test.js @@ -29,7 +29,10 @@ describe('APM', function () { instrumentation.on('started', filterForCommands('insert', started)); instrumentation.on('succeeded', filterForCommands('insert', succeeded)); - let client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + let client = this.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); return client .connect() @@ -48,7 +51,10 @@ describe('APM', function () { .then(() => { started = []; succeeded = []; - client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + client = this.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); return client.connect(); }) @@ -117,7 +123,10 @@ describe('APM', function () { test: function () { const started = []; const succeeded = []; - const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = this.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); client.on('commandStarted', filterForCommands('insert', started)); client.on('commandSucceeded', filterForCommands('insert', succeeded)); @@ -143,7 +152,10 @@ describe('APM', function () { const started = []; const succeeded = []; const self = this; - const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = this.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); client.on('commandStarted', filterForCommands('insert', started)); client.on('commandSucceeded', filterForCommands('insert', succeeded)); @@ -170,7 +182,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); client.on('commandStarted', filterForCommands('listCollections', started)); client.on('commandSucceeded', filterForCommands('listCollections', succeeded)); @@ -205,7 +220,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['listIndexes', 'find']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -318,7 +336,10 @@ describe('APM', function () { const started = []; const succeeded = []; const failed = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['find', 'getMore', 'killCursors']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -388,7 +409,10 @@ describe('APM', function () { const started = []; const succeeded = []; const failed = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['find', 'getMore', 'killCursors']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -443,7 +467,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['insert', 'update', 'delete']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -482,7 +509,10 @@ describe('APM', function () { const started = []; const succeeded = []; const failed = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['find', 'getMore', 'killCursors', 'explain']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -527,7 +557,10 @@ describe('APM', function () { const started = []; const succeeded = []; const failed = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['getnonce']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -556,7 +589,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['update']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -588,7 +624,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['update']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -620,7 +659,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['delete']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -647,7 +689,10 @@ describe('APM', function () { test: function () { const self = this; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); return client.connect().then(client => { const db = client.db(self.configuration.db); @@ -694,7 +739,10 @@ describe('APM', function () { const docs = []; for (let i = 0; i < 2500; i++) docs.push({ a: i }); - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['aggregate', 'getMore']; client.on('commandStarted', filterForCommands(desiredEvents, started)); @@ -737,7 +785,10 @@ describe('APM', function () { const self = this; const started = []; const succeeded = []; - const client = self.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); + const client = self.configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, monitorCommands: true } + ); const desiredEvents = ['listCollections']; client.on('commandStarted', filterForCommands(desiredEvents, started)); diff --git a/test/functional/db.test.js b/test/functional/db.test.js index 8b1445d1e38..2279f45ece3 100644 --- a/test/functional/db.test.js +++ b/test/functional/db.test.js @@ -41,8 +41,7 @@ describe('Db', function () { test: function (done) { var configuration = this.configuration; var client = configuration.newClient(configuration.writeConcernMax(), { - maxPoolSize: 1, - + maxPoolSize: 1 }); client.connect(function (err, client) { expect(err).to.not.exist; @@ -78,8 +77,7 @@ describe('Db', function () { test: function (done) { let configuration = this.configuration; let client = configuration.newClient(configuration.writeConcernMax(), { - maxPoolSize: 1, - + maxPoolSize: 1 }); client.connect(function (err, client) { diff --git a/test/functional/readconcern.test.js b/test/functional/readconcern.test.js index 2b4c28ae6da..b923c486964 100644 --- a/test/functional/readconcern.test.js +++ b/test/functional/readconcern.test.js @@ -395,7 +395,10 @@ describe('ReadConcern', function () { test: function (done) { // Get a new instance const configuration = this.configuration; - client = configuration.newClient({ w: 1 }, { maxPoolSize: 1, readConcern: { level: 'local' } }); + client = configuration.newClient( + { w: 1 }, + { maxPoolSize: 1, readConcern: { level: 'local' } } + ); client.connect((err, client) => { expect(err).to.not.exist; const db = client.db(configuration.db); diff --git a/test/functional/sessions.test.js b/test/functional/sessions.test.js index 3b8ac958a1c..dcc58caeb21 100644 --- a/test/functional/sessions.test.js +++ b/test/functional/sessions.test.js @@ -12,10 +12,7 @@ const test = { commands: { started: [], succeeded: [] }, setup: function (config) { this.commands = { started: [], succeeded: [] }; - this.client = config.newClient( - { w: 1 }, - { maxPoolSize: 1, monitorCommands: true } - ); + this.client = config.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true }); this.client.on('commandStarted', event => { if (ignoredCommands.indexOf(event.commandName) === -1) { diff --git a/test/unit/core/connection_string.test.js b/test/unit/core/connection_string.test.js index 40d9ff0d9c5..b61e649234d 100644 --- a/test/unit/core/connection_string.test.js +++ b/test/unit/core/connection_string.test.js @@ -220,72 +220,72 @@ describe('Connection String', function () { suites.forEach(suite => { describe(suite.name, function () { suite.tests.forEach(test => { - // it(test.description, { - // metadata: { requires: { topology: 'single' } }, - // test: function (done) { - // if (skipTests.indexOf(test.description) !== -1) { - // return this.skip(); - // } - - // const valid = test.valid; - // parseConnectionString(test.uri, { caseTranslate: false }, function (err, result) { - // if (valid === false) { - // expect(err).to.exist; - // expect(err).to.be.instanceOf(MongoParseError); - // expect(result).to.not.exist; - // } else { - // expect(err).to.not.exist; - // expect(result).to.exist; - - // // remove data we don't track - // if (test.auth && test.auth.password === '') { - // test.auth.password = null; - // } - - // if (test.hosts != null) { - // test.hosts = test.hosts.map(host => { - // delete host.type; - // host.host = punycode.toASCII(host.host); - // return host; - // }); - - // // remove values that require no validation - // test.hosts.forEach(host => { - // Object.keys(host).forEach(key => { - // if (host[key] == null) delete host[key]; - // }); - // }); - - // expect(result.hosts).to.containSubset(test.hosts); - // } - - // if (test.auth) { - // if (test.auth.db != null) { - // expect(result.auth).to.have.property('db'); - // expect(result.auth.db).to.eql(test.auth.db); - // } - - // if (test.auth.username != null) { - // expect(result.auth).to.have.property('username'); - // expect(result.auth.username).to.eql(test.auth.username); - // } - - // if (test.auth.password != null) { - // expect(result.auth).to.have.property('password'); - // expect(result.auth.password).to.eql(test.auth.password); - // } - // } - - // if (test.options != null) { - // // it's possible we have options which are not explicitly included in the spec test - // expect(result.options).to.deep.include(test.options); - // } - // } - - // done(); - // }); - // } - // }); + it(test.description, { + metadata: { requires: { topology: 'single' } }, + test: function (done) { + if (skipTests.indexOf(test.description) !== -1) { + return this.skip(); + } + + const valid = test.valid; + parseConnectionString(test.uri, { caseTranslate: false }, function (err, result) { + if (valid === false) { + expect(err).to.exist; + expect(err).to.be.instanceOf(MongoParseError); + expect(result).to.not.exist; + } else { + expect(err).to.not.exist; + expect(result).to.exist; + + // remove data we don't track + if (test.auth && test.auth.password === '') { + test.auth.password = null; + } + + if (test.hosts != null) { + test.hosts = test.hosts.map(host => { + delete host.type; + host.host = punycode.toASCII(host.host); + return host; + }); + + // remove values that require no validation + test.hosts.forEach(host => { + Object.keys(host).forEach(key => { + if (host[key] == null) delete host[key]; + }); + }); + + expect(result.hosts).to.containSubset(test.hosts); + } + + if (test.auth) { + if (test.auth.db != null) { + expect(result.auth).to.have.property('db'); + expect(result.auth.db).to.eql(test.auth.db); + } + + if (test.auth.username != null) { + expect(result.auth).to.have.property('username'); + expect(result.auth.username).to.eql(test.auth.username); + } + + if (test.auth.password != null) { + expect(result.auth).to.have.property('password'); + expect(result.auth.password).to.eql(test.auth.password); + } + } + + if (test.options != null) { + // it's possible we have options which are not explicitly included in the spec test + expect(result.options).to.deep.include(test.options); + } + } + + done(); + }); + } + }); it(`${test.description} -- new MongoOptions parser`, function () { if (skipTests.includes(test.description)) {