diff --git a/go.mod b/go.mod index 72b1b81..1aea0cb 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module source.toby3d.me/toby3d/hacks go 1.22.0 + +require github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5a8d551 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/testing/testing.go b/testing/testing.go index 10b9796..8e30c3d 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -2,13 +2,14 @@ package testing import ( - "bytes" "errors" "flag" "io" "os" "path/filepath" "testing" + + "github.com/google/go-cmp/cmp" ) //nolint:gochecknoglobals // сompiler global flags cannot be read from within tests @@ -67,7 +68,7 @@ func GoldenEqual(tb testing.TB, output io.Reader) { tb.Fatal("cannot read golden file data:", err) } - if !bytes.Equal(actual, expect) { - tb.Errorf("the test output does not match the contents of %s.golden file", tb.Name()) + if diff := cmp.Diff(actual, expect); diff != "" { + tb.Error(diff) } }