diff --git a/mock/mock.go b/mock/mock.go index 88bec6426..f04914c6d 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -213,7 +213,7 @@ func (m *Mock) On(methodName string, arguments ...interface{}) *Call { // Recording and responding to activity // */ -func (m *Mock) FindExpectedCall(method string, arguments ...interface{}) (int, *Call) { +func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) { m.mutex.Lock() defer m.mutex.Unlock() for i, call := range m.ExpectedCalls { @@ -287,11 +287,8 @@ func (m *Mock) Called(arguments ...interface{}) Arguments { } parts := strings.Split(functionPath, ".") functionName := parts[len(parts)-1] - return m.MethodCalled(functionName, arguments...) -} -func (m *Mock) MethodCalled(functionName string, arguments ...interface{}) Arguments { - found, call := m.FindExpectedCall(functionName, arguments...) + found, call := m.findExpectedCall(functionName, arguments...) if found < 0 { // we have to fail here - because we don't know what to do diff --git a/mock/mock_test.go b/mock/mock_test.go index 208dab7ef..a68162312 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -2,11 +2,10 @@ package mock import ( "errors" - "testing" - "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "testing" + "time" ) /* @@ -562,7 +561,7 @@ func Test_Mock_findExpectedCall(t *testing.T) { m.On("Two", 2).Return("two") m.On("Two", 3).Return("three") - f, c := m.FindExpectedCall("Two", 3) + f, c := m.findExpectedCall("Two", 3) if assert.Equal(t, 2, f) { if assert.NotNil(t, c) { @@ -581,7 +580,7 @@ func Test_Mock_findExpectedCall_For_Unknown_Method(t *testing.T) { m.On("Two", 2).Return("two") m.On("Two", 3).Return("three") - f, _ := m.FindExpectedCall("Two") + f, _ := m.findExpectedCall("Two") assert.Equal(t, -1, f) @@ -595,7 +594,7 @@ func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) { m.On("Two", 3).Return("three").Twice() m.On("Two", 3).Return("three").Times(8) - f, c := m.FindExpectedCall("Two", 3) + f, c := m.findExpectedCall("Two", 3) if assert.Equal(t, 2, f) { if assert.NotNil(t, c) { @@ -1185,15 +1184,3 @@ func Test_WaitUntil_Parallel(t *testing.T) { // Allow the first call to execute, so the second one executes afterwards ch2 <- time.Now() } - -func Test_MethodCalled(t *testing.T) { - m := new(Mock) - m.On("foo", "hello").Return("world") - - found, _ := m.FindExpectedCall("foo", "hello") - require.True(t, found >= 0) - retArgs := m.MethodCalled("foo", "hello") - require.True(t, len(retArgs) == 1) - require.Equal(t, "world", retArgs[0]) - m.AssertExpectations(t) -}