diff --git a/go.mod b/go.mod index 97d9b69ae..2bf27de35 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/aws/aws-sdk-go v1.25.37 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/gobwas/glob v0.2.3 + github.com/google/go-cmp v0.3.1 github.com/google/uuid v1.1.1 github.com/julienschmidt/httprouter v1.2.0 ) diff --git a/go.sum b/go.sum index 538763b38..cc48dc82a 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= diff --git a/golang-github-osbuild-composer.spec b/golang-github-osbuild-composer.spec index 8ed2f44c3..d0ee0c3df 100644 --- a/golang-github-osbuild-composer.spec +++ b/golang-github-osbuild-composer.spec @@ -27,6 +27,7 @@ BuildRequires: golang(github.com/coreos/go-systemd/activation) BuildRequires: golang(github.com/google/uuid) BuildRequires: golang(github.com/julienschmidt/httprouter) BuildRequires: golang(github.com/gobwas/glob) +BuildRequires: golang(github.com/google/go-cmp/cmp) Requires: systemd Requires: osbuild diff --git a/internal/test/helpers.go b/internal/test/helpers.go index 6cd77f153..1e9b74e92 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -12,6 +12,8 @@ import ( "reflect" "strings" "testing" + + "github.com/google/go-cmp/cmp" ) type API interface { @@ -137,8 +139,8 @@ func TestRoute(t *testing.T, api API, external bool, method, path, body string, dropFields(reply, ignoreFields...) dropFields(expected, ignoreFields...) - if !reflect.DeepEqual(reply, expected) { - t.Errorf("%s: reply != expected:\n reply: %s\nexpected: %s", path, strings.TrimSpace(string(replyJSON)), expectedJSON) + if diff := cmp.Diff(expected, reply); diff != "" { + t.Errorf("%s: reply != expected:\n reply: %s\nexpected: %s\ndiff: %s", path, strings.TrimSpace(string(replyJSON)), expectedJSON, diff) return } }