testify
testify copied to clipboard
Nil actual type made AnythingOfType matcher panic
Summary
Passing an actual value of type nil via a Mock into the argument matcher for AnythingOfType in a Mock causes a panic.
Changes
- Handle nil types up front when checking actual types against mock.AnythingOfType before calling any methods on the reflect.Type, which will be nil if the value was a nil interface.
- Change formatting of the expected type from
Name()
toString()
because Name is emptystring for pointer and some other types.
Motivation
Someone may expect their mock to be called with a nil interface, we should not panic in this case.
Related issues
Closes #1209
I ran into this issue as well. Is there any activity on this PR fixing this issue?
I ran into this issue as well. Is there any activity on this PR fixing this issue?
I believe the state is that fixing this well would be a breaking change, so not until Testify 2.0, and I think we should do that. But the comments above object to something which is not a regression, so I think this change can be merged into 1.x.