diff --git a/gomock/callset.go b/gomock/callset.go index b046b525..7bb056bc 100644 --- a/gomock/callset.go +++ b/gomock/callset.go @@ -84,7 +84,11 @@ func (cs callSet) FindMatch(receiver interface{}, method string, args []interfac for _, call := range exhausted { if err := call.matches(args); err != nil { _, _ = fmt.Fprintf(&callsErrors, "\n%v", err) + continue } + _, _ = fmt.Fprintf( + &callsErrors, "all expected calls of the method %q have been exhausted for that received", method, + ) } if len(expected)+len(exhausted) == 0 { diff --git a/gomock/callset_test.go b/gomock/callset_test.go index 7fc711a4..a2835f34 100644 --- a/gomock/callset_test.go +++ b/gomock/callset_test.go @@ -74,3 +74,26 @@ func TestCallSetRemove(t *testing.T) { cs.Remove(c) } } + +func TestCallSetFindMatch(t *testing.T) { + t.Run("call is exhausted", func(t *testing.T) { + cs := callSet{} + var receiver interface{} = "TestReceiver" + method := "TestMethod" + args := []interface{}{} + + c1 := newCall(t, receiver, method, reflect.TypeOf(receiverType{}.Func)) + cs.exhausted = map[callSetKey][]*Call{ + callSetKey{receiver: receiver, fname: method}: []*Call{c1}, + } + + _, err := cs.FindMatch(receiver, method, args) + if err == nil { + t.Fatal("expected error, but was nil") + } + + if err.Error() == "" { + t.Fatal("expected error to have message, but was empty") + } + }) +} diff --git a/sample/user_test.go b/sample/user_test.go index d1de99cd..1267107f 100644 --- a/sample/user_test.go +++ b/sample/user_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/golang/mock/sample" + user "github.com/golang/mock/sample" "github.com/golang/mock/sample/imp1" mock_user "github.com/golang/mock/sample/mock_user" )