frankban / quicktest

Quick helpers for testing Go applications
MIT License
529 stars 27 forks source link

WIP: report unexpected output involving non-ptr Error method #127

Closed mvdan closed 2 years ago

mvdan commented 2 years ago

(see commit message)

mvdan commented 2 years ago

Also worth noting that I can't use new(*errTargetNonPtr), as that will never match.

frankban commented 2 years ago

Interesting! *errTargetNonPtr still implements error, so when it is formatted it matches the error case and therefore e<msg> is used, rather than the more generic fmt.Sprintf("%# v", pretty.Formatter(v)). We should probably more explicitly format "as" in the checker.

mvdan commented 2 years ago

Indeed; as is about the target type, not value, so IMO it should always print the type.

mvdan commented 2 years ago

Please feel free to take over the fix, by the way. I'm not familiar with the codebase, so it's not clear to me what bit of code should get fixed. Hopefully you can just reuse the test.

frankban commented 2 years ago

Please feel free to take over the fix, by the way. I'm not familiar with the codebase, so it's not clear to me what bit of code should get fixed. Hopefully you can just reuse the test.

Sure, I proposed a possible fix at https://github.com/frankban/quicktest/pull/128

mvdan commented 2 years ago

Thanks! Closing in favor of that then.