approvals / go-approval-tests

Apache License 2.0
86 stars 22 forks source link

Add reporter based on the command line `diff` tool #29

Closed christoffer-gamrath closed 2 years ago

christoffer-gamrath commented 2 years ago

On behalf of my employer, Maersk, I am contributing this PR which consists of three changes:

  1. A reporter that prints the diff using the command line diff tool. The implementation is straight forwardly adapted from the other reporters. I believe adding this reporter will fix issue #27 in many cases given that Linux servers are likely to have some version of diff installed.
  2. Adding a call to t.Helper in the verify functions, so that when approval tests fail, the stacktrace will point to the call of the verify function instead of to some line within the library. This makes it easier for the user of the library to understand which assertion in their tests failed.
  3. Changing some pointers to interface values to plain interface values. It is unnecessary and unidiomatic to have pointers to interfaces in Go. Interfaces are already pointers internally. This should not affect any behavior.

Looking forward to your feedback.

Thanks, Christoffer G. Thomsen Senior Software Engineer Maersk

hjwk commented 2 years ago

@emilybache, @objarni

objarni commented 2 years ago

Nice work @christoffer-thomsen !

I'm not a maintainer of this library, but as long as there are some automatic tests for the provided features I think this should just be merged 😊🎉

emilybache commented 2 years ago

great stuff, happy to have your input. Thankyou!