From ab301b7940decdec67fa802c04e000186c07b650 Mon Sep 17 00:00:00 2001 From: Bracken Dawson Date: Tue, 27 Jul 2021 00:56:15 +0100 Subject: [PATCH] Only say another call if it has been called before --- mock/mock.go | 2 +- mock/mock_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 4f9904457..ae5cf1201 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -457,7 +457,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen m.fail("mock: Unexpected Method Call\n-----------------------------\n\n%s\n\nMust not be called before%s:\n\n%s", callString(call.Method, call.Arguments, true), func() (s string) { - if requirement.Repeatability+requirement.totalCalls > 1 { + if requirement.totalCalls > 0 { s = " another call of" } if call.Parent != requirement.Parent { diff --git a/mock/mock_test.go b/mock/mock_test.go index 84301bb3c..cda62ed74 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -738,7 +738,7 @@ func Test_Mock_Return_NotBefore_Out_Of_Order(t *testing.T) { b := mockedService. On("TheExampleMethod", 1, 2, 3). - Return(4, nil) + Return(4, nil).Twice() c := mockedService. On("TheExampleMethod2", true). Return().