@@ -321,22 +321,22 @@ func compareStartedEvents(mt *mtest.T, expectations []*cmdStartedEvt, id0, id1 b
321
321
}
322
322
323
323
var evt * event.CommandStartedEvent
324
- if expected .CommandName != "" {
325
- // skip events not in expectations
326
- for {
327
- evt = mt .GetStartedEvent ()
328
- if evt == nil {
329
- return fmt .Errorf ("expected CommandStartedEvent %s, got nil" , expected .CommandName )
330
- }
331
- if v , ok := expectedCmds [evt .CommandName ]; ok && v {
332
- break
333
- }
324
+ // skip events not in expectations
325
+ for {
326
+ evt = mt .GetStartedEvent ()
327
+ if evt == nil {
328
+ return fmt .Errorf ("expected CommandStartedEvent %s, got nil" , expected .CommandName )
334
329
}
335
-
336
- if expected .CommandName != evt .CommandName {
337
- return fmt .Errorf ("command name mismatch for started event; expected %s, got %s" , expected .CommandName , evt .CommandName )
330
+ if expected .CommandName != "" {
331
+ break
332
+ } else if v , ok := expectedCmds [evt .CommandName ]; ok && v {
333
+ break
338
334
}
339
335
}
336
+
337
+ if expected .CommandName != "" && expected .CommandName != evt .CommandName {
338
+ return fmt .Errorf ("command name mismatch for started event; expected %s, got %s" , expected .CommandName , evt .CommandName )
339
+ }
340
340
if expected .DatabaseName != "" && expected .DatabaseName != evt .DatabaseName {
341
341
return fmt .Errorf ("database name mismatch; expected %s, got %s" , expected .DatabaseName , evt .DatabaseName )
342
342
}
@@ -460,23 +460,23 @@ func compareSucceededEvents(mt *mtest.T, expectations []*cmdSucceededEvt) error
460
460
}
461
461
462
462
var evt * event.CommandSucceededEvent
463
- if expected .CommandName != "" {
464
- // skip events not in expectations
465
- for expected .CommandName != "" {
466
- evt = mt .GetSucceededEvent ()
467
- if evt == nil {
468
- return fmt .Errorf ("expected CommandSucceededEvent %s, got nil" , expected .CommandName )
469
- }
470
- if v , ok := expectedCmds [evt .CommandName ]; ok && v {
471
- break
472
- }
463
+ // skip events not in expectations
464
+ for {
465
+ evt = mt .GetSucceededEvent ()
466
+ if evt == nil {
467
+ return fmt .Errorf ("expected CommandSucceededEvent %s, got nil" , expected .CommandName )
473
468
}
474
-
475
- if expected .CommandName != evt .CommandName {
476
- return fmt .Errorf ("command name mismatch for succeeded event; expected %s, got %s" , expected .CommandName , evt .CommandName )
469
+ if expected .CommandName != "" {
470
+ break
471
+ } else if v , ok := expectedCmds [evt .CommandName ]; ok && v {
472
+ break
477
473
}
478
474
}
479
475
476
+ if expected .CommandName != "" && expected .CommandName != evt .CommandName {
477
+ return fmt .Errorf ("command name mismatch for succeeded event; expected %s, got %s" , expected .CommandName , evt .CommandName )
478
+ }
479
+
480
480
eElems , err := expected .Reply .Elements ()
481
481
if err != nil {
482
482
return fmt .Errorf ("error getting expected reply elements: %s" , err )
@@ -523,22 +523,22 @@ func compareFailedEvents(mt *mtest.T, expectations []*cmdFailedEvt) error {
523
523
}
524
524
525
525
var evt * event.CommandFailedEvent
526
- if expected .CommandName != "" {
527
- // skip events not in expectations
528
- for expected .CommandName != "" {
529
- evt = mt .GetFailedEvent ()
530
- if evt == nil {
531
- return fmt .Errorf ("expected CommandFailedEvent %s, got nil" , expected .CommandName )
532
- }
533
- if v , ok := expectedCmds [evt .CommandName ]; ok && v {
534
- break
535
- }
526
+ // skip events not in expectations
527
+ for {
528
+ evt = mt .GetFailedEvent ()
529
+ if evt == nil {
530
+ return fmt .Errorf ("expected CommandFailedEvent %s, got nil" , expected .CommandName )
536
531
}
537
-
538
- if expected .CommandName != evt .CommandName {
539
- return fmt .Errorf ("command name mismatch for failed event; expected %s, got %s" , expected .CommandName , evt .CommandName )
532
+ if expected .CommandName != "" {
533
+ break
534
+ } else if v , ok := expectedCmds [evt .CommandName ]; ok && v {
535
+ break
540
536
}
541
537
}
538
+
539
+ if expected .CommandName != "" && expected .CommandName != evt .CommandName {
540
+ return fmt .Errorf ("command name mismatch for failed event; expected %s, got %s" , expected .CommandName , evt .CommandName )
541
+ }
542
542
return nil
543
543
}
544
544
for idx , expected := range expectations {
0 commit comments