@@ -362,35 +362,43 @@ describe('CRUD API explain option', function () {
362
362
}
363
363
) ;
364
364
365
- test ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
366
- const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
367
- const timeout = await cursor . explain ( { verbosity : 'queryPlanner ' } ) . catch ( e => e ) ;
368
- expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
369
-
370
- const [
371
- {
372
- command : { maxTimeMS }
373
- }
374
- ] = commands ;
375
-
376
- expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
377
- } ) ;
365
+ it (
366
+ 'the explain command has the calculated maxTimeMS value attached' ,
367
+ { requires : { mongodb : '>=4.4 ' } } ,
368
+ async function ( ) {
369
+ const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
370
+ const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
371
+ expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
372
+
373
+ const [
374
+ {
375
+ command : { maxTimeMS }
376
+ }
377
+ ] = commands ;
378
378
379
- test ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
380
- const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
381
- const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
382
- expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
379
+ expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
380
+ }
381
+ ) ;
383
382
384
- const [
385
- {
386
- command : {
387
- explain : { maxTimeMS }
383
+ it (
384
+ 'the explained command does not have a maxTimeMS value attached' ,
385
+ { requires : { mongodb : '>=4.4' } } ,
386
+ async function ( ) {
387
+ const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
388
+ const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
389
+ expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
390
+
391
+ const [
392
+ {
393
+ command : {
394
+ explain : { maxTimeMS }
395
+ }
388
396
}
389
- }
390
- ] = commands ;
397
+ ] = commands ;
391
398
392
- expect ( maxTimeMS ) . not . to . exist ;
393
- } ) ;
399
+ expect ( maxTimeMS ) . not . to . exist ;
400
+ }
401
+ ) ;
394
402
} ) ;
395
403
396
404
describe ( 'when timeoutMS and maxTimeMS are both provided' , function ( ) {
@@ -433,73 +441,85 @@ describe('CRUD API explain option', function () {
433
441
}
434
442
) ;
435
443
436
- test ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
437
- const timeout = await client
438
- . db ( 'foo' )
439
- . collection ( 'bar' )
440
- . deleteMany (
441
- { } ,
444
+ it (
445
+ 'the explain command has the calculated maxTimeMS value attached' ,
446
+ { requires : { mongodb : '>=4.4' } } ,
447
+ async function ( ) {
448
+ const timeout = await client
449
+ . db ( 'foo' )
450
+ . collection ( 'bar' )
451
+ . deleteMany (
452
+ { } ,
453
+ {
454
+ timeoutMS : 1000 ,
455
+ explain : { verbosity : 'queryPlanner' }
456
+ }
457
+ )
458
+ . catch ( e => e ) ;
459
+
460
+ expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
461
+
462
+ const [
442
463
{
443
- timeoutMS : 1000 ,
444
- explain : { verbosity : 'queryPlanner' }
464
+ command : { maxTimeMS }
445
465
}
446
- )
447
- . catch ( e => e ) ;
466
+ ] = commands ;
448
467
449
- expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
468
+ expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
469
+ }
470
+ ) ;
450
471
451
- const [
452
- {
453
- command : { maxTimeMS }
454
- }
455
- ] = commands ;
472
+ it (
473
+ 'the explained command does not have a maxTimeMS value attached' ,
474
+ { requires : { mongodb : '>=4.4' } } ,
475
+ async function ( ) {
476
+ const timeout = await client
477
+ . db ( 'foo' )
478
+ . collection ( 'bar' )
479
+ . deleteMany (
480
+ { } ,
481
+ {
482
+ timeoutMS : 1000 ,
483
+ explain : { verbosity : 'queryPlanner' }
484
+ }
485
+ )
486
+ . catch ( e => e ) ;
456
487
457
- expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
458
- } ) ;
488
+ expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
459
489
460
- test ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
461
- const timeout = await client
462
- . db ( 'foo' )
463
- . collection ( 'bar' )
464
- . deleteMany (
465
- { } ,
490
+ const [
466
491
{
467
- timeoutMS : 1000 ,
468
- explain : { verbosity : 'queryPlanner' }
469
- }
470
- )
471
- . catch ( e => e ) ;
472
-
473
- expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
474
-
475
- const [
476
- {
477
- command : {
478
- explain : { maxTimeMS }
492
+ command : {
493
+ explain : { maxTimeMS }
494
+ }
479
495
}
480
- }
481
- ] = commands ;
496
+ ] = commands ;
482
497
483
- expect ( maxTimeMS ) . not . to . exist ;
484
- } ) ;
498
+ expect ( maxTimeMS ) . not . to . exist ;
499
+ }
500
+ ) ;
485
501
} ) ;
486
502
487
503
describe ( 'when timeoutMS and maxTimeMS are both provided' , function ( ) {
488
- test ( 'an error is thrown indicating incompatibility of those options' , async function ( ) {
489
- const error = await client
490
- . db ( 'foo' )
491
- . collection ( 'bar' )
492
- . deleteMany (
493
- { } ,
494
- {
495
- timeoutMS : 1000 ,
496
- explain : { verbosity : 'queryPlanner' , maxTimeMS : 1000 }
497
- }
498
- )
499
- . catch ( e => e ) ;
504
+ it (
505
+ 'an error is thrown indicating incompatibility of those options' ,
506
+ { requires : { mongodb : '>=4.4' } } ,
507
+ async function ( ) {
508
+ const error = await client
509
+ . db ( 'foo' )
510
+ . collection ( 'bar' )
511
+ . deleteMany (
512
+ { } ,
513
+ {
514
+ timeoutMS : 1000 ,
515
+ explain : { verbosity : 'queryPlanner' , maxTimeMS : 1000 }
516
+ }
517
+ )
518
+ . catch ( e => e ) ;
500
519
501
- expect ( error ) . to . match ( / C a n n o t u s e m a x T i m e M S w i t h t i m e o u t M S f o r e x p l a i n c o m m a n d s / ) ;
502
- } ) ;
520
+ expect ( error ) . to . match ( / C a n n o t u s e m a x T i m e M S w i t h t i m e o u t M S f o r e x p l a i n c o m m a n d s / ) ;
521
+ }
522
+ ) ;
503
523
} ) ;
504
524
} ) ;
505
525
0 commit comments