testify icon indicating copy to clipboard operation
testify copied to clipboard

Give mock.Anything its own type so it can't be mistaken for a string

Open dbravender opened this issue 4 years ago • 2 comments

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.

dbravender avatar Mar 20 '21 16:03 dbravender

Related: #1441

dolmen avatar Oct 31 '23 00:10 dolmen

An alternate proposal: #1442

dolmen avatar Oct 31 '23 00:10 dolmen