mirror of https://github.com/stretchr/testify.git
Fix use of AnythingOfType with AssertCalled
parent
37614ac277
commit
939e66beb2
|
@ -296,11 +296,11 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter
|
||||||
return true
|
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 {
|
for _, call := range m.Calls {
|
||||||
if call.Method == methodName {
|
if call.Method == methodName {
|
||||||
|
|
||||||
_, differences := call.Arguments.Diff(arguments)
|
_, differences := Arguments(expected).Diff(call.Arguments)
|
||||||
|
|
||||||
if differences == 0 {
|
if differences == 0 {
|
||||||
// found the expected call
|
// found the expected call
|
||||||
|
|
|
@ -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) {
|
func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
|
||||||
|
|
||||||
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
|
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
|
||||||
|
|
Loading…
Reference in New Issue