@@ -447,15 +447,19 @@ func executeGridFSOperation(mt *mtest.T, bucket *gridfs.Bucket, op *operation) e
447
447
}
448
448
449
449
func executeTestRunnerOperation (mt * mtest.T , testCase * testCase , op * operation , sess mongo.Session ) error {
450
+ if sess == nil {
451
+ return fmt .Errorf ("received unexpected nil session" )
452
+ }
453
+
450
454
var clientSession * session.Client
451
- if sess != nil {
452
- xsess , ok := sess .(mongo.XSession )
453
- if ! ok {
454
- return fmt .Errorf ("expected session type %T to implement mongo.XSession" , sess )
455
- }
456
- clientSession = xsess .ClientSession ()
455
+ xsess , ok := sess .(mongo.XSession )
456
+ if ! ok {
457
+ return fmt .Errorf ("expected session type %T to implement mongo.XSession" , sess )
457
458
}
458
459
460
+ clientSession = xsess .ClientSession ()
461
+ assert .NotNil (mt , clientSession , "expected valid session, got nil" )
462
+
459
463
switch op .Name {
460
464
case "targetedFailPoint" :
461
465
fpDoc := op .Arguments .Lookup ("failPoint" )
@@ -480,23 +484,29 @@ func executeTestRunnerOperation(mt *mtest.T, testCase *testCase, op *operation,
480
484
mt .TrackFailPoint (fp .ConfigureFailPoint )
481
485
case "configureFailPoint" :
482
486
fp , err := op .Arguments .LookupErr ("failPoint" )
483
- assert .Nil (mt , err , "failPoint not found in arguments" )
487
+ if err != nil {
488
+ return fmt .Errorf ("unable to find 'failPoint' in arguments: %v" , err )
489
+ }
484
490
mt .SetFailPointFromDocument (fp .Document ())
485
491
case "assertSessionTransactionState" :
486
492
stateVal , err := op .Arguments .LookupErr ("state" )
487
- assert .Nil (mt , err , "state not found in arguments" )
493
+ if err != nil {
494
+ return fmt .Errorf ("unable to find 'state' in arguments: %v" , err )
495
+ }
488
496
expectedState , ok := stateVal .StringValueOK ()
489
- assert .True (mt , ok , "state argument is not a string" )
497
+ if ! ok {
498
+ return fmt .Errorf ("expected 'state' argument to be string" )
499
+ }
490
500
491
- assert .NotNil (mt , clientSession , "expected valid session, got nil" )
492
501
actualState := clientSession .TransactionState .String ()
493
502
494
503
// actualState should match expectedState, but "in progress" is the same as
495
504
// "in_progress".
496
505
stateMatch := actualState == expectedState ||
497
506
actualState == "in progress" && expectedState == "in_progress"
498
- assert .True (mt , stateMatch , "expected transaction state %v, got %v" ,
499
- expectedState , actualState )
507
+ if ! stateMatch {
508
+ return fmt .Errorf ("expected transaction state %v, got %v" , expectedState , actualState )
509
+ }
500
510
case "assertSessionPinned" :
501
511
if clientSession .PinnedServer == nil {
502
512
return errors .New ("expected pinned server, got nil" )
0 commit comments