From 5b6ad3e96aaec427aeaa3584eeab72bc50f9af09 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Tue, 10 Oct 2023 16:13:03 -0400 Subject: [PATCH] fix test (#3787) --- go.mod | 2 +- internal/porter_app/test/porter_app_to_yaml_test.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 4685748de4..8012a5a485 100644 --- a/go.mod +++ b/go.mod @@ -243,7 +243,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.5.9 github.com/google/go-containerregistry v0.9.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect diff --git a/internal/porter_app/test/porter_app_to_yaml_test.go b/internal/porter_app/test/porter_app_to_yaml_test.go index 35ff15b0dd..40fc18b281 100644 --- a/internal/porter_app/test/porter_app_to_yaml_test.go +++ b/internal/porter_app/test/porter_app_to_yaml_test.go @@ -4,10 +4,9 @@ import ( "context" "fmt" "os" - "reflect" "testing" - "github.com/kr/pretty" + "github.com/google/go-cmp/cmp" "github.com/matryer/is" porterv1 "github.com/porter-dev/api-contracts/generated/go/porter/v1" "github.com/porter-dev/porter/internal/porter_app" @@ -44,8 +43,8 @@ func TestPorterAppToYAML(t *testing.T) { func diffPorterAppWithOriginalYamlTest(t *testing.T, is *is.I, wantYaml []byte, got v2.PorterApp) { t.Helper() - var want map[string]interface{} - err := yaml.Unmarshal(wantYaml, &want) + var wantMap map[string]interface{} + err := yaml.Unmarshal(wantYaml, &wantMap) is.NoErr(err) gotYaml, err := yaml.Marshal(got) @@ -55,8 +54,7 @@ func diffPorterAppWithOriginalYamlTest(t *testing.T, is *is.I, wantYaml []byte, err = yaml.Unmarshal(gotYaml, &gotMap) is.NoErr(err) - // Compare the maps for equality - if !reflect.DeepEqual(want, gotMap) { - t.Errorf("Maps are not equal. Diff: %v", pretty.Diff(want, gotMap)) + if diff := cmp.Diff(wantMap, gotMap); diff != "" { + t.Errorf("diff between want and got: %s", diff) } }