-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow use of mock.Anything/etc inside slices #1348
Conversation
The whitespace changes are because Go 1.19 added stricter comment formatting for go doc and this project is currently formatted as 1.18. If you don't want attribution on all those other lines you can drop them and use a 1.18 gofmt. |
No worries. If that's the way it is, all of the comments will wind up getting reformatted eventually. :) |
Please rebase this PR on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase to cleanup gofmt changes.
I glanced at this when the rebase request first went up, but there have been a lot of code changes since I made the PR. It's not just formatting at this point; I'd need to go back through the code and fully understand how to merge the functionality of those interim changes. Sorry, but I moved on from this months ago. Don't have time to dig into it again right now. |
darn i was really looking forward to this feature - found it linked in the vektra mockery docs here. Is there a way to make a single |
Hey all, I opened up a pull request working to get this rebased / working as desired. Open to any feedback. |
Summary
Adds the ability for mock expectations to be defined with mock.Anything or mock.AnythingOfType as elements within a slice. This is mainly intended for variadic functions in a new PR for mockery, but can apply to any slice parameter.
Dunno why so many whitespace changes in comments are here, guess my VSCode format-on-save had opinions. 😄
Changes
compareElements
function on each pair. Since this function already handles Anything and AnythingOfType comparisons (as well as argumentMatcher, etc), those values can now be used inside the slice.Motivation
Mainly this is to support backward compatibility with the current version of Mockery while implementing some new enhancements to how it handles variadic functions. The way mockery currently handles variadic arguments has sort of inadvertently enabled the behavior that this PR will make available to everyone.
Example usage (if applicable)