Fix use of AnythingOfType with AssertCalled

pull/47/head
Pieter Noordhuis 2014-04-01 15:52:39 -07:00
parent 37614ac277
commit 939e66beb2
2 changed files with 14 additions and 2 deletions

View File

@ -296,11 +296,11 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter
return true
}
func (m *Mock) methodWasCalled(methodName string, arguments []interface{}) bool {
func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool {
for _, call := range m.Calls {
if call.Method == methodName {
_, differences := call.Arguments.Diff(arguments)
_, differences := Arguments(expected).Diff(call.Arguments)
if differences == 0 {
// found the expected call

View File

@ -473,6 +473,18 @@ func Test_Mock_AssertCalled(t *testing.T) {
}
func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("Test_Mock_AssertCalled_WithAnythingOfTypeArgument", Anything, Anything, Anything).Return()
mockedService.Mock.Called(1, "two", []uint8("three"))
assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled_WithAnythingOfTypeArgument", AnythingOfType("int"), AnythingOfType("string"), AnythingOfType("[]uint8")))
}
func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)