diff --git a/go.mod b/go.mod index 9b80e1a..14bb2a5 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/go-resty/resty/v2 v2.1.0 github.com/gofrs/uuid v3.2.0+incompatible github.com/golang/mock v1.4.1 - github.com/google/go-cmp v0.4.0 // indirect + github.com/google/go-cmp v0.4.0 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.4 github.com/spf13/cobra v0.0.5 diff --git a/go.sum b/go.sum index f31eb13..c497164 100644 --- a/go.sum +++ b/go.sum @@ -97,6 +97,7 @@ golang.org/x/tools v0.0.0-20200125223703-d33eef8e6825/go.mod h1:TB2adYChydJhpapK golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20170206182103-3d017632ea10/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/olympics/main_test.go b/olympics/main_test.go index efeec19..a6531ec 100644 --- a/olympics/main_test.go +++ b/olympics/main_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/go-resty/resty/v2" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" "gitlab.com/slon/shad-go/tools/testtool" ) @@ -100,7 +101,18 @@ func TestServer_valid(t *testing.T) { require.Equal(t, http.StatusOK, resp.StatusCode()) require.Contains(t, resp.Header().Get("Content-Type"), "application/json") - require.JSONEq(t, string(out), resp.String()) + var got interface{} + err = json.Unmarshal(resp.Body(), &got) + if err != nil { + t.Fatalf("Could not parse response body: %v", err) + } + + var want interface{} + _ = json.Unmarshal(out, &want) + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Response diff (-want +got):\n%s", diff) + } }) } })