Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Nov 19, 2020
1 parent f311817 commit 22bdd05
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/operations/map_reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
85 changes: 68 additions & 17 deletions test/functional/apm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
})
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions test/functional/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion test/functional/readconcern.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/functional/sessions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
132 changes: 66 additions & 66 deletions test/unit/core/connection_string.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 22bdd05

Please sign in to comment.