testify
testify copied to clipboard
Give mock.Anything its own type so it can't be mistaken for a string
Summary
This change makes mock.Anything its own type
Changes
- Introduce a custom internal type for
mock.Anything
Motivation
While refactoring tests to use strongly typed On_ calls generated by mockery with this PR https://github.com/vektra/mockery/pull/375 I started getting unexpected test failures because some tests were using mock.Anything where a string was expected and the functions were receiving "mock.Anything" as the parameter. mock.Anything should have its own type to make situations like this a compile-time error. I don't believe this change should affect existing tests that use mock.Anything.
Related: #1441
An alternate proposal: #1442