From 939e66beb2200d0db8ca1365b9760fb177c26f05 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Tue, 1 Apr 2014 15:52:39 -0700 Subject: [PATCH] Fix use of AnythingOfType with AssertCalled --- mock/mock.go | 4 ++-- mock/mock_test.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 4320e6f..eb00367 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -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 diff --git a/mock/mock_test.go b/mock/mock_test.go index cd06451..353d810 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -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)