Skip to content

Commit fce8064

Browse files
changes
1 parent ae05194 commit fce8064

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

test/integration/crud/explain.test.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ describe('CRUD API explain option', function () {
307307
};
308308
const commands: ExplainStartedEvent[] = [];
309309

310+
function test(description: string, f: () => Promise<void>) {
311+
return it(description, { requires: { mongodb: '>=4.4' } }, f);
312+
}
313+
310314
beforeEach(async function () {
311315
client = this.configuration.newClient({}, { monitorCommands: true });
312316
client.on('commandStarted', filterForCommands('explain', commands));
@@ -330,13 +334,13 @@ describe('CRUD API explain option', function () {
330334

331335
describe('when a cursor api is being explained', function () {
332336
describe('when timeoutMS is provided', function () {
333-
it('the explain command respects timeoutMS', async function () {
337+
test('the explain command respects timeoutMS', async function () {
334338
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 1000 });
335339
const timeout = await cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e);
336340
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
337341
});
338342

339-
it('the explain command has the calculated maxTimeMS value attached', async function () {
343+
test('the explain command has the calculated maxTimeMS value attached', async function () {
340344
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 1000 });
341345
const timeout = await cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e);
342346
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
@@ -350,7 +354,7 @@ describe('CRUD API explain option', function () {
350354
expect(maxTimeMS).to.be.a('number');
351355
});
352356

353-
it('the explained command does not have a maxTimeMS value attached', async function () {
357+
test('the explained command does not have a maxTimeMS value attached', async function () {
354358
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 1000 });
355359
const timeout = await cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e);
356360
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
@@ -368,7 +372,7 @@ describe('CRUD API explain option', function () {
368372
});
369373

370374
describe('when timeoutMS and maxTimeMS are both provided', function () {
371-
it('an error is thrown indicating incompatibility of those options', async function () {
375+
test('an error is thrown indicating incompatibility of those options', async function () {
372376
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 1000 });
373377
const error = await cursor
374378
.explain({ verbosity: 'queryPlanner', maxTimeMS: 1000 })
@@ -380,7 +384,7 @@ describe('CRUD API explain option', function () {
380384

381385
describe('when a non-cursor api is being explained', function () {
382386
describe('when timeoutMS is provided', function () {
383-
it('the explain command respects timeoutMS', async function () {
387+
test('the explain command respects timeoutMS', async function () {
384388
const timeout = await client
385389
.db('foo')
386390
.collection('bar')
@@ -395,7 +399,7 @@ describe('CRUD API explain option', function () {
395399
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
396400
});
397401

398-
it('the explain command has the calculated maxTimeMS value attached', async function () {
402+
test('the explain command has the calculated maxTimeMS value attached', async function () {
399403
const timeout = await client
400404
.db('foo')
401405
.collection('bar')
@@ -419,7 +423,7 @@ describe('CRUD API explain option', function () {
419423
expect(maxTimeMS).to.be.a('number');
420424
});
421425

422-
it('the explained command does not have a maxTimeMS value attached', async function () {
426+
test('the explained command does not have a maxTimeMS value attached', async function () {
423427
const timeout = await client
424428
.db('foo')
425429
.collection('bar')
@@ -447,7 +451,7 @@ describe('CRUD API explain option', function () {
447451
});
448452

449453
describe('when timeoutMS and maxTimeMS are both provided', function () {
450-
it('an error is thrown indicating incompatibility of those options', async function () {
454+
test('an error is thrown indicating incompatibility of those options', async function () {
451455
const error = await client
452456
.db('foo')
453457
.collection('bar')
@@ -466,7 +470,7 @@ describe('CRUD API explain option', function () {
466470
});
467471

468472
describe('when find({}, { explain: ...}) is used with timeoutMS', function () {
469-
it('an error is thrown indicating that explain is not supported with timeoutMS for this API', async function () {
473+
test('an error is thrown indicating that explain is not supported with timeoutMS for this API', async function () {
470474
const error = await client
471475
.db('foo')
472476
.collection('bar')
@@ -487,7 +491,7 @@ describe('CRUD API explain option', function () {
487491
});
488492

489493
describe('when aggregate({}, { explain: ...}) is used with timeoutMS', function () {
490-
it('an error is thrown indicating that explain is not supported with timeoutMS for this API', async function () {
494+
test('an error is thrown indicating that explain is not supported with timeoutMS for this API', async function () {
491495
const error = await client
492496
.db('foo')
493497
.collection('bar')
@@ -506,15 +510,15 @@ describe('CRUD API explain option', function () {
506510

507511
describe('fluent api timeoutMS precedence and inheritance', function () {
508512
describe('find({}, { timeoutMS }).explain()', function () {
509-
it('respects the timeoutMS from the find options', async function () {
513+
test('respects the timeoutMS from the find options', async function () {
510514
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 1000 });
511515
const timeout = await cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e);
512516
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
513517
});
514518
});
515519

516520
describe('find().explain({}, { timeoutMS })', function () {
517-
it('respects the timeoutMS from the explain helper', async function () {
521+
test('respects the timeoutMS from the explain helper', async function () {
518522
const cursor = client.db('foo').collection('bar').find();
519523
const timeout = await cursor
520524
.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 })
@@ -524,7 +528,7 @@ describe('CRUD API explain option', function () {
524528
});
525529

526530
describe('find({}, { timeoutMS} ).explain({}, { timeoutMS })', function () {
527-
it('the timeoutMS from the explain helper has precedence', async function () {
531+
test('the timeoutMS from the explain helper has precedence', async function () {
528532
const cursor = client.db('foo').collection('bar').find({}, { timeoutMS: 2000 });
529533
const timeout = await cursor
530534
.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 })
@@ -534,15 +538,15 @@ describe('CRUD API explain option', function () {
534538
});
535539

536540
describe('aggregate([], { timeoutMS }).explain()', function () {
537-
it('respects the timeoutMS from the find options', async function () {
541+
test('respects the timeoutMS from the find options', async function () {
538542
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 1000 });
539543
const timeout = await cursor.explain({ verbosity: 'queryPlanner' }).catch(e => e);
540544
expect(timeout).to.be.instanceOf(MongoOperationTimeoutError);
541545
});
542546
});
543547

544548
describe('aggregate([], { timeoutMS })', function () {
545-
it('respects the timeoutMS from the explain helper', async function () {
549+
test('respects the timeoutMS from the explain helper', async function () {
546550
const cursor = client.db('foo').collection('bar').aggregate();
547551
const timeout = await cursor
548552
.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 })
@@ -552,7 +556,7 @@ describe('CRUD API explain option', function () {
552556
});
553557

554558
describe('aggregate([], { timeoutMS} ).explain({}, { timeoutMS })', function () {
555-
it('the timeoutMS from the explain helper has precedence', async function () {
559+
test('the timeoutMS from the explain helper has precedence', async function () {
556560
const cursor = client.db('foo').collection('bar').aggregate([], { timeoutMS: 2000 });
557561
const timeout = await cursor
558562
.explain({ verbosity: 'queryPlanner' }, { timeoutMS: 1000 })

0 commit comments

Comments
 (0)