testify
testify copied to clipboard
#562: assert.NoError() and assert.Error() now behave correctly when a nil error struct is supplied
Fixes #562
assert.Nil already does this correctly by checking via reflection if the supplied value isn't nil wrapped in an interface in order to not give false results. I think assert.NoError should do the same.
I can imagine that this could be considered as breaking backwards compatibility, so perhaps there could be new functions to do this instead of modifying the behaviour of the existing ones. But I think it's quite useful to be able to use something like assert.NoError(err) on custom error types.
Perhaps something like this:
assert.NoCustomError(err) assert.CustomError(err)
Could you please add a unit test covering the use-case you're solving? If I understand correctly, this change only fixes for the following scenario:
type MyCustomError {
err error
}
a := MyCustomError{err=nil}
?
Any plans to merge this change?
Looks like bad change leading to implicit bugs. @dolmen I propose to close this PR
#562 is invalid. This patch will break correct behaviour instead of fixing.
Thanks @Antonboom for review.