Skip to content

Commit 7d74b14

Browse files
committed
updates
1 parent 928555a commit 7d74b14

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

mongo/integration/cmd_monitoring_helpers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func compareStartedEvent(mt *mtest.T, expectation *expectation, id0, id1 bson.Ra
313313
}
314314

315315
if expected.CommandName != "" && expected.CommandName != evt.CommandName {
316-
return fmt.Errorf("command name mismatch; expected %s, got %s", expected.CommandName, evt.CommandName)
316+
return fmt.Errorf("command name mismatch for started event; expected %s, got %s", expected.CommandName, evt.CommandName)
317317
}
318318
if expected.DatabaseName != "" && expected.DatabaseName != evt.DatabaseName {
319319
return fmt.Errorf("database name mismatch; expected %s, got %s", expected.DatabaseName, evt.DatabaseName)
@@ -429,7 +429,7 @@ func compareSucceededEvent(mt *mtest.T, expectation *expectation) error {
429429
}
430430

431431
if expected.CommandName != "" && expected.CommandName != evt.CommandName {
432-
return fmt.Errorf("command name mismatch; expected %s, got %s", expected.CommandName, evt.CommandName)
432+
return fmt.Errorf("command name mismatch for succeeded event; expected %s, got %s", expected.CommandName, evt.CommandName)
433433
}
434434

435435
eElems, err := expected.Reply.Elements()
@@ -469,7 +469,7 @@ func compareFailedEvent(mt *mtest.T, expectation *expectation) error {
469469
}
470470

471471
if expected.CommandName != "" && expected.CommandName != evt.CommandName {
472-
return fmt.Errorf("command name mismatch; expected %s, got %s", expected.CommandName, evt.CommandName)
472+
return fmt.Errorf("command name mismatch for failed event; expected %s, got %s", expected.CommandName, evt.CommandName)
473473
}
474474
return nil
475475
}

mongo/integration/mtest/mongotest.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,12 @@ func (t *T) ClearMockResponses() {
299299
func (t *T) GetStartedEvent() *event.CommandStartedEvent {
300300
// TODO(GODRIVER-2075): GetStartedEvent documents that it returns the most recent event, but actually returns the first
301301
// TODO event. Update either the documentation or implementation.
302-
if len(t.started) == 0 {
302+
l := len(t.started)
303+
if l == 0 {
303304
return nil
304305
}
305-
e := t.started[0]
306-
t.started = t.started[1:]
306+
e := t.started[l-1]
307+
t.started = t.started[:l-1]
307308
return e
308309
}
309310

@@ -312,11 +313,12 @@ func (t *T) GetStartedEvent() *event.CommandStartedEvent {
312313
func (t *T) GetSucceededEvent() *event.CommandSucceededEvent {
313314
// TODO(GODRIVER-2075): GetSucceededEvent documents that it returns the most recent event, but actually returns the
314315
// TODO first event. Update either the documentation or implementation.
315-
if len(t.succeeded) == 0 {
316+
l := len(t.succeeded)
317+
if l == 0 {
316318
return nil
317319
}
318-
e := t.succeeded[0]
319-
t.succeeded = t.succeeded[1:]
320+
e := t.succeeded[l-1]
321+
t.succeeded = t.succeeded[:l-1]
320322
return e
321323
}
322324

@@ -325,11 +327,12 @@ func (t *T) GetSucceededEvent() *event.CommandSucceededEvent {
325327
func (t *T) GetFailedEvent() *event.CommandFailedEvent {
326328
// TODO(GODRIVER-2075): GetFailedEvent documents that it returns the most recent event, but actually returns the first
327329
// TODO event. Update either the documentation or implementation.
328-
if len(t.failed) == 0 {
330+
l := len(t.failed)
331+
if l == 0 {
329332
return nil
330333
}
331-
e := t.failed[0]
332-
t.failed = t.failed[1:]
334+
e := t.failed[l-1]
335+
t.failed = t.failed[:l-1]
333336
return e
334337
}
335338

0 commit comments

Comments
 (0)