Skip to content

Commit f64488b

Browse files
committed
fix: lint
1 parent 1f19ce6 commit f64488b

File tree

7 files changed

+179
-239
lines changed

7 files changed

+179
-239
lines changed

test/integration/auth/mongodb_aws.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { removeAuthFromConnectionString } = require('../../tools/utils');
44
const sinon = require('sinon');
55
const http = require('http');
66
const { performance } = require('perf_hooks');
7-
const { MongoAWSError, MongoError } = require('../../../src');
7+
const { MongoAWSError } = require('../../../src');
88

99
describe('MONGODB-AWS', function () {
1010
beforeEach(function () {

test/integration/collection-management/collection.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ describe('Collection', function () {
650650
}
651651

652652
it('countDocuments should return appropriate error if aggregation fails with callback given', function (done) {
653-
const replyHandler = () => {};
653+
const replyHandler = () => null;
654654
const executeCountDocuments = (collection, close) => {
655655
collection.countDocuments(err => {
656656
expect(err).to.exist;
@@ -671,7 +671,7 @@ describe('Collection', function () {
671671
});
672672

673673
it('countDocuments should error if aggregation fails using Promises', function (done) {
674-
const replyHandler = () => {};
674+
const replyHandler = () => null;
675675
const executeCountDocuments = (collection, close) => {
676676
collection
677677
.countDocuments()
@@ -804,7 +804,7 @@ describe('Collection', function () {
804804
const client = configuration.newClient({ w: 1 });
805805

806806
let finish = err => {
807-
finish = () => {};
807+
finish = () => null;
808808
client.close(_err => done(err || _err));
809809
};
810810

@@ -840,7 +840,7 @@ describe('Collection', function () {
840840
collection.updateOne(
841841
{},
842842
[{ $set: { a: 1 } }, { $set: { b: 1 } }, { $set: { d: 1 } }],
843-
configuration.writeConcernMax(),
843+
{ writeConcern: { w: 'majority' } },
844844
(err, r) => {
845845
expect(err).to.not.exist;
846846
expect(r).property('matchedCount').to.equal(0);

test/integration/command-monitoring/command_monitoring.spec.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Command Monitoring spec tests', function () {
1919
// It may be worth seeing if we can improve on this, as we might need the
2020
// behavior in other future YAML tests.
2121
const maybeLong = val => (typeof val.equals === 'function' ? val.toNumber() : val);
22-
function apmExpect(actual, expected, parentKey) {
22+
function apmExpect(actual: any, expected: any, parentKey?: any) {
2323
Object.keys(expected).forEach(key => {
2424
expect(actual).to.include.keys([key]);
2525

@@ -212,7 +212,9 @@ describe('Command Monitoring spec tests', function () {
212212
// Execute find
213213
return cursor
214214
.toArray()
215-
.catch(() => {} /* ignore */)
215+
.catch(() => {
216+
/* ignore */
217+
})
216218
.then(() =>
217219
test.expectations.forEach(expectation =>
218220
validateExpectations(expectation, monitoringResults)
@@ -243,9 +245,10 @@ describe('Command Monitoring spec tests', function () {
243245
loadSpecTests('command-monitoring/legacy').forEach(scenario => {
244246
describe(scenario.name, function () {
245247
scenario.tests.forEach(test => {
246-
const requirements: MongoDBMetadataUI['requires'] = {
247-
topology: ['single', 'replicaset', 'sharded']
248-
};
248+
const requirements = {
249+
topology: ['single', 'replicaset', 'sharded'],
250+
mongodb: undefined
251+
} as any;
249252
if (test.ignore_if_server_version_greater_than) {
250253
requirements.mongodb = `<${test.ignore_if_server_version_greater_than}`;
251254
} else if (test.ignore_if_server_version_less_than) {
@@ -258,8 +261,9 @@ describe('Command Monitoring spec tests', function () {
258261
);
259262
}
260263

264+
const metadata: MongoDBMetadataUI = { requires: requirements };
261265
it(test.description, {
262-
metadata: { requires: requirements },
266+
metadata,
263267
test: async function () {
264268
if (
265269
test.description ===

test/integration/command-monitoring/command_monitoring.test.ts

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('APM', function () {
4343
test: function () {
4444
const started = [];
4545
const succeeded = [];
46-
const self = this;
46+
4747
const client = this.configuration.newClient(
4848
{ writeConcern: { w: 1 } },
4949
{ maxPoolSize: 1, monitorCommands: true }
@@ -52,7 +52,7 @@ describe('APM', function () {
5252
client.on('commandStarted', filterForCommands('insert', started));
5353
client.on('commandSucceeded', filterForCommands('insert', succeeded));
5454

55-
const db = client.db(self.configuration.db);
55+
const db = client.db(this.configuration.db);
5656
const collection = db.collection('apm_test_cursor');
5757
return collection.insertMany([{ a: 1 }, { a: 2 }, { a: 3 }]).then(r => {
5858
expect(r).property('insertedCount').to.equal(3);
@@ -69,22 +69,21 @@ describe('APM', function () {
6969
metadata: { requires: { topology: ['replicaset'], mongodb: '>=3.0.0' } },
7070

7171
test: function () {
72-
const self = this;
7372
const started = [];
7473
const succeeded = [];
75-
const client = self.configuration.newClient(
74+
const client = this.configuration.newClient(
7675
{ writeConcern: { w: 1 } },
7776
{ maxPoolSize: 1, monitorCommands: true }
7877
);
7978

8079
client.on('commandStarted', filterForCommands('listCollections', started));
8180
client.on('commandSucceeded', filterForCommands('listCollections', succeeded));
8281

83-
const db = client.db(self.configuration.db);
82+
const db = client.db(this.configuration.db);
8483

8584
return db
8685
.collection('apm_test_list_collections')
87-
.insertOne({ a: 1 }, self.configuration.writeConcernMax())
86+
.insertOne({ a: 1 }, this.configuration.writeConcernMax())
8887
.then(r => {
8988
expect(r).property('insertedId').to.exist;
9089
return db.listCollections({}, { readPreference: ReadPreference.primary }).toArray();
@@ -104,10 +103,9 @@ describe('APM', function () {
104103
metadata: { requires: { topology: ['replicaset'], mongodb: '>=3.0.0' } },
105104

106105
test: function () {
107-
const self = this;
108106
const started = [];
109107
const succeeded = [];
110-
const client = self.configuration.newClient(
108+
const client = this.configuration.newClient(
111109
{ writeConcern: { w: 1 } },
112110
{ maxPoolSize: 1, monitorCommands: true }
113111
);
@@ -116,11 +114,11 @@ describe('APM', function () {
116114
client.on('commandStarted', filterForCommands(desiredEvents, started));
117115
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
118116

119-
const db = client.db(self.configuration.db);
117+
const db = client.db(this.configuration.db);
120118

121119
return db
122120
.collection('apm_test_list_collections')
123-
.insertOne({ a: 1 }, self.configuration.writeConcernMax())
121+
.insertOne({ a: 1 }, this.configuration.writeConcernMax())
124122
.then(r => {
125123
expect(r).property('insertedId').to.exist;
126124

@@ -148,11 +146,10 @@ describe('APM', function () {
148146
metadata: { requires: { topology: ['single', 'replicaset'] } },
149147

150148
test: function () {
151-
const self = this;
152149
const started = [];
153150
const succeeded = [];
154151
const failed = [];
155-
const client = self.configuration.newClient(
152+
const client = this.configuration.newClient(
156153
{ writeConcern: { w: 1 } },
157154
{ maxPoolSize: 1, monitorCommands: true }
158155
);
@@ -162,7 +159,7 @@ describe('APM', function () {
162159
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
163160
client.on('commandFailed', filterForCommands(desiredEvents, failed));
164161

165-
const db = client.db(self.configuration.db);
162+
const db = client.db(this.configuration.db);
166163

167164
// Drop the collection
168165
return db
@@ -220,11 +217,10 @@ describe('APM', function () {
220217
metadata: { requires: { topology: ['single', 'replicaset'], mongodb: '>=2.6.0' } },
221218

222219
test: function () {
223-
const self = this;
224220
const started = [];
225221
const succeeded = [];
226222
const failed = [];
227-
const client = self.configuration.newClient(
223+
const client = this.configuration.newClient(
228224
{ writeConcern: { w: 1 } },
229225
{ maxPoolSize: 1, monitorCommands: true }
230226
);
@@ -234,7 +230,7 @@ describe('APM', function () {
234230
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
235231
client.on('commandFailed', filterForCommands(desiredEvents, failed));
236232

237-
const db = client.db(self.configuration.db);
233+
const db = client.db(this.configuration.db);
238234

239235
// Drop the collection
240236
return db
@@ -277,10 +273,9 @@ describe('APM', function () {
277273
metadata: { requires: { topology: ['single', 'replicaset'] } },
278274

279275
test: function () {
280-
const self = this;
281276
const started = [];
282277
const succeeded = [];
283-
const client = self.configuration.newClient(
278+
const client = this.configuration.newClient(
284279
{ writeConcern: { w: 1 } },
285280
{ maxPoolSize: 1, monitorCommands: true }
286281
);
@@ -289,7 +284,7 @@ describe('APM', function () {
289284
client.on('commandStarted', filterForCommands(desiredEvents, started));
290285
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
291286

292-
const db = client.db(self.configuration.db);
287+
const db = client.db(this.configuration.db);
293288
return db
294289
.collection('apm_test_3')
295290
.bulkWrite(
@@ -316,11 +311,10 @@ describe('APM', function () {
316311
metadata: { requires: { topology: ['single', 'replicaset'] } },
317312

318313
test: function () {
319-
const self = this;
320314
const started = [];
321315
const succeeded = [];
322316
const failed = [];
323-
const client = self.configuration.newClient(
317+
const client = this.configuration.newClient(
324318
{ writeConcern: { w: 1 } },
325319
{ maxPoolSize: 1, monitorCommands: true }
326320
);
@@ -330,7 +324,7 @@ describe('APM', function () {
330324
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
331325
client.on('commandFailed', filterForCommands(desiredEvents, failed));
332326

333-
const db = client.db(self.configuration.db);
327+
const db = client.db(this.configuration.db);
334328

335329
return db
336330
.collection('apm_test_2')
@@ -364,11 +358,10 @@ describe('APM', function () {
364358
metadata: { requires: { topology: ['single', 'replicaset'] } },
365359

366360
test: function () {
367-
const self = this;
368361
const started = [];
369362
const succeeded = [];
370363
const failed = [];
371-
const client = self.configuration.newClient(
364+
const client = this.configuration.newClient(
372365
{ writeConcern: { w: 1 } },
373366
{ maxPoolSize: 1, monitorCommands: true }
374367
);
@@ -379,7 +372,7 @@ describe('APM', function () {
379372
client.on('commandFailed', filterForCommands(desiredEvents, failed));
380373

381374
return client
382-
.db(self.configuration.db)
375+
.db(this.configuration.db)
383376
.command({ getnonce: true })
384377
.then(r => {
385378
expect(r).to.exist;
@@ -397,10 +390,9 @@ describe('APM', function () {
397390
metadata: { requires: { topology: ['single', 'replicaset'] } },
398391

399392
test: function () {
400-
const self = this;
401393
const started = [];
402394
const succeeded = [];
403-
const client = self.configuration.newClient(
395+
const client = this.configuration.newClient(
404396
{ writeConcern: { w: 1 } },
405397
{ maxPoolSize: 1, monitorCommands: true }
406398
);
@@ -410,7 +402,7 @@ describe('APM', function () {
410402
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
411403

412404
return client
413-
.db(self.configuration.db)
405+
.db(this.configuration.db)
414406
.collection('apm_test_u_1')
415407
.updateOne({ a: 1 }, { $set: { b: 1 } }, { upsert: true })
416408
.then(r => {
@@ -428,10 +420,9 @@ describe('APM', function () {
428420
metadata: { requires: { topology: ['single', 'replicaset'] } },
429421

430422
test: function () {
431-
const self = this;
432423
const started = [];
433424
const succeeded = [];
434-
const client = self.configuration.newClient(
425+
const client = this.configuration.newClient(
435426
{ writeConcern: { w: 1 } },
436427
{ maxPoolSize: 1, monitorCommands: true }
437428
);
@@ -441,7 +432,7 @@ describe('APM', function () {
441432
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
442433

443434
return client
444-
.db(self.configuration.db)
435+
.db(this.configuration.db)
445436
.collection('apm_test_u_2')
446437
.updateMany({ a: 1 }, { $set: { b: 1 } }, { upsert: true })
447438
.then(r => {
@@ -459,10 +450,9 @@ describe('APM', function () {
459450
metadata: { requires: { topology: ['single', 'replicaset'] } },
460451

461452
test: function () {
462-
const self = this;
463453
const started = [];
464454
const succeeded = [];
465-
const client = self.configuration.newClient(
455+
const client = this.configuration.newClient(
466456
{ writeConcern: { w: 1 } },
467457
{ maxPoolSize: 1, monitorCommands: true }
468458
);
@@ -472,7 +462,7 @@ describe('APM', function () {
472462
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
473463

474464
return client
475-
.db(self.configuration.db)
465+
.db(this.configuration.db)
476466
.collection('apm_test_u_3')
477467
.deleteOne({ a: 1 })
478468
.then(r => {
@@ -490,13 +480,12 @@ describe('APM', function () {
490480
metadata: { requires: { topology: ['single', 'replicaset'], mongodb: '<=3.0.x' } },
491481

492482
test: function () {
493-
const self = this;
494-
const client = self.configuration.newClient(
483+
const client = this.configuration.newClient(
495484
{ writeConcern: { w: 1 } },
496485
{ maxPoolSize: 1, monitorCommands: true }
497486
);
498487

499-
const db = client.db(self.configuration.db);
488+
const db = client.db(this.configuration.db);
500489
const admindb = db.admin();
501490
let cursorCountBefore;
502491
let cursorCountAfter;
@@ -531,15 +520,14 @@ describe('APM', function () {
531520
metadata: { requires: { topology: ['single', 'replicaset'], mongodb: '>=3.0.0' } },
532521

533522
test: function () {
534-
const self = this;
535523
const started = [];
536524
const succeeded = [];
537525

538526
// Generate docs
539527
const docs = [];
540528
for (let i = 0; i < 2500; i++) docs.push({ a: i });
541529

542-
const client = self.configuration.newClient(
530+
const client = this.configuration.newClient(
543531
{ writeConcern: { w: 1 } },
544532
{ maxPoolSize: 1, monitorCommands: true }
545533
);
@@ -548,7 +536,7 @@ describe('APM', function () {
548536
client.on('commandStarted', filterForCommands(desiredEvents, started));
549537
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
550538

551-
const db = client.db(self.configuration.db);
539+
const db = client.db(this.configuration.db);
552540
return db
553541
.collection('apm_test_u_4')
554542
.drop()
@@ -580,10 +568,9 @@ describe('APM', function () {
580568
it('should correctly decorate the apm result for listCollections with cursorId', {
581569
metadata: { requires: { topology: ['single', 'replicaset'], mongodb: '>=3.0.0' } },
582570
test: function () {
583-
const self = this;
584571
const started = [];
585572
const succeeded = [];
586-
const client = self.configuration.newClient(
573+
const client = this.configuration.newClient(
587574
{ writeConcern: { w: 1 } },
588575
{ maxPoolSize: 1, monitorCommands: true }
589576
);
@@ -592,7 +579,7 @@ describe('APM', function () {
592579
client.on('commandStarted', filterForCommands(desiredEvents, started));
593580
client.on('commandSucceeded', filterForCommands(desiredEvents, succeeded));
594581

595-
const db = client.db(self.configuration.db);
582+
const db = client.db(this.configuration.db);
596583

597584
const promises = [];
598585
for (let i = 0; i < 20; i++) {

0 commit comments

Comments
 (0)