Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@ type Trap struct {
unreleasedCalls int
}

func (t *Trap) String() string {
return fmt.Sprintf("%s(..., %v)", t.fn.String(), t.tags)
}

func (t *Trap) catch(c *apiCall) {
select {
case t.calls <- c:
Expand All @@ -763,12 +767,13 @@ func (t *Trap) Close() {
defer t.mock.mu.Unlock()
select {
case <-t.done:
t.mock.tb.Logf("trap %s already Closed()", t)
return // already closed
default:
}
if t.unreleasedCalls != 0 {
t.mock.tb.Helper()
t.mock.tb.Errorf("trap Closed() with %d unreleased calls", t.unreleasedCalls)
t.mock.tb.Errorf("trap %s Closed() with %d unreleased calls", t, t.unreleasedCalls)
}
for i, tr := range t.mock.traps {
if t == tr {
Expand Down Expand Up @@ -814,7 +819,7 @@ func (t *Trap) MustWait(ctx context.Context) *Call {
t.mock.tb.Helper()
c, err := t.Wait(ctx)
if err != nil {
t.mock.tb.Fatalf("context expired while waiting for trap: %s", err.Error())
t.mock.tb.Fatalf("context expired while waiting for trap %s: %s", t, err.Error())
}
return c
}
Expand Down