@@ -406,6 +406,9 @@ describe('MongoErrors', () => {
406
406
// 8 - below server version 4.4
407
407
// 9 - above server version 4.4
408
408
409
+ const ABOVE_4_4 = 9 ;
410
+ const BELOW_4_4 = 8 ;
411
+
409
412
const tests : {
410
413
description : string ;
411
414
result : boolean ;
@@ -416,25 +419,25 @@ describe('MongoErrors', () => {
416
419
description : 'a plain error' ,
417
420
result : false ,
418
421
error : new Error ( 'do not retry me!' ) ,
419
- maxWireVersion : 8
422
+ maxWireVersion : BELOW_4_4
420
423
} ,
421
424
{
422
425
description : 'a MongoError with no code nor label' ,
423
426
result : false ,
424
427
error : new MongoError ( 'do not retry me!' ) ,
425
- maxWireVersion : 8
428
+ maxWireVersion : BELOW_4_4
426
429
} ,
427
430
{
428
431
description : 'network error' ,
429
432
result : true ,
430
433
error : new MongoNetworkError ( 'socket bad, try again' ) ,
431
- maxWireVersion : 8
434
+ maxWireVersion : BELOW_4_4
432
435
} ,
433
436
{
434
437
description : 'a MongoWriteConcernError with no code nor label' ,
435
438
result : false ,
436
439
error : new MongoWriteConcernError ( { message : 'empty wc error' } ) ,
437
- maxWireVersion : 8
440
+ maxWireVersion : BELOW_4_4
438
441
} ,
439
442
{
440
443
description : 'a MongoWriteConcernError with a random label' ,
@@ -443,31 +446,31 @@ describe('MongoErrors', () => {
443
446
{ message : 'random label' } ,
444
447
{ errorLabels : [ 'myLabel' ] }
445
448
) ,
446
- maxWireVersion : 8
449
+ maxWireVersion : BELOW_4_4
447
450
} ,
448
451
{
449
452
description : 'a MongoWriteConcernError with a retryable code above server 4.4' ,
450
453
result : false ,
451
454
error : new MongoWriteConcernError ( { } , { code : 262 } ) ,
452
- maxWireVersion : 9
455
+ maxWireVersion : ABOVE_4_4
453
456
} ,
454
457
{
455
458
description : 'a MongoWriteConcernError with a retryable code below server 4.4' ,
456
459
result : true ,
457
460
error : new MongoWriteConcernError ( { } , { code : 262 } ) ,
458
- maxWireVersion : 8
461
+ maxWireVersion : BELOW_4_4
459
462
} ,
460
463
{
461
464
description : 'a MongoWriteConcernError with a RetryableWriteError label below server 4.4' ,
462
465
result : true ,
463
466
error : new MongoWriteConcernError ( { } , { errorLabels : [ 'RetryableWriteError' ] } ) ,
464
- maxWireVersion : 8
467
+ maxWireVersion : BELOW_4_4
465
468
} ,
466
469
{
467
470
description : 'a MongoWriteConcernError with a RetryableWriteError label above server 4.4' ,
468
471
result : false ,
469
472
error : new MongoWriteConcernError ( { } , { errorLabels : [ 'RetryableWriteError' ] } ) ,
470
- maxWireVersion : 9
473
+ maxWireVersion : ABOVE_4_4
471
474
} ,
472
475
{
473
476
description : 'any MongoError with a RetryableWriteError label' ,
@@ -479,7 +482,7 @@ describe('MongoErrors', () => {
479
482
error . addErrorLabel ( 'RetryableWriteError' ) ;
480
483
return error ;
481
484
} ) ( ) ,
482
- maxWireVersion : 9
485
+ maxWireVersion : ABOVE_4_4
483
486
}
484
487
] ;
485
488
for ( const { description, result, error, maxWireVersion } of tests ) {
0 commit comments