mirror of https://github.com/stretchr/testify.git
Now expectations for method calls abides the repeatability argument.
parent
40e4720477
commit
ab70c9a56c
|
@ -242,11 +242,15 @@ func (m *Mock) AssertExpectations(t *testing.T) bool {
|
|||
|
||||
// iterate through each expectation
|
||||
for _, expectedCall := range m.ExpectedCalls {
|
||||
if !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) {
|
||||
switch {
|
||||
case !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments):
|
||||
somethingMissing = true
|
||||
failedExpectations++
|
||||
t.Logf("\u274C\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
|
||||
} else {
|
||||
case expectedCall.Repeatability > 0:
|
||||
somethingMissing = true
|
||||
failedExpectations++
|
||||
default:
|
||||
t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,7 +387,7 @@ func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
|
|||
|
||||
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
|
||||
|
||||
mockedService.Mock.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Once()
|
||||
mockedService.Mock.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Twice()
|
||||
|
||||
tt := new(testing.T)
|
||||
assert.False(t, mockedService.AssertExpectations(tt))
|
||||
|
@ -395,6 +395,10 @@ func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
|
|||
// make the call now
|
||||
mockedService.Mock.Called(1, 2, 3)
|
||||
|
||||
assert.False(t, mockedService.AssertExpectations(tt))
|
||||
|
||||
mockedService.Mock.Called(1, 2, 3)
|
||||
|
||||
// now assert expectations
|
||||
assert.True(t, mockedService.AssertExpectations(tt))
|
||||
|
||||
|
|
Loading…
Reference in New Issue