Repository navigation
Conversation
Signed-off-by: Yshuro <yshuro1080@gmail.com>
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Ran Unset() on calls set up with AnythingOfType, Anything, MatchedBy and nil. Master panicked on all but Anything; here each removes only its own call.
| // in-place filter slice for calls to be removed - iterate from 0'th to last skipping unnecessary ones | ||
| var index int // write index | ||
| for _, call := range c.Parent.ExpectedCalls { | ||
| if call == c { |
There was a problem hiding this comment.
With two identical expectations (On("F", 1).Once() then On("F", 1)), unsetting the second still removes both, because the argument match below also runs, same as on master. Now that the pointer check is here, is the argument match still needed?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix Call.Unset() panics when called on mock expectations configured with type matchers or custom matchers (mock.AnythingOfType, mock.IsType, mock.MatchedBy).
Changes
Motivation
Calling call.Unset() on an expectation configured with mock.AnythingOfType or other matchers previously panicked because Arguments.Diff() treated matcher arguments as concrete values and failed type checks against themselves, causing Unset() to report that the expected call could not be found.
Related issues
Closes #1599