Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .Unset method to mock #982

Merged
merged 11 commits into from
Jun 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
pdufour committed Jun 22, 2022
commit 422fe49b9b07394bf0f27d8468e74159ba07519d
14 changes: 4 additions & 10 deletions mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,19 +532,13 @@ func Test_Mock_UnsetIfAlreadyUnsetFails(t *testing.T) {
On("TheExampleMethod1", 1, 1).
Return(1)

assert.Equal(t, 1, mockedService.ExpectedCalls)
assert.Equal(t, 1, len(mockedService.ExpectedCalls))
mock1.Unset()
assert.Equal(t, 0, len(mockedService.ExpectedCalls))

defer func() {
if r := recover(); r != nil {
matchingExp := regexp.MustCompile(
`.*Could not find expected call.*`)
assert.Regexp(t, matchingExp, r)
}
}()

mock1.Unset()
assert.Panics(t, func() {
mock1.Unset()
})

assert.Equal(t, 0, len(mockedService.ExpectedCalls))
}
Expand Down