From 58a46241316fbd9b86df685309c6fe5ae9b1a1ea Mon Sep 17 00:00:00 2001 From: Karim Radhouani Date: Thu, 25 Apr 2024 13:43:07 -0700 Subject: [PATCH] fix tests --- pkg/api/target_test.go | 3 +-- pkg/loaders/loaders_test.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/api/target_test.go b/pkg/api/target_test.go index 24c860ab..ee893885 100644 --- a/pkg/api/target_test.go +++ b/pkg/api/target_test.go @@ -12,7 +12,6 @@ import ( "testing" "github.com/AlekSi/pointer" - "github.com/google/go-cmp/cmp" "github.com/openconfig/gnmic/pkg/api/types" ) @@ -145,7 +144,7 @@ func TestNewTarget(t *testing.T) { t.Errorf("failed at %q: %v", name, err) t.Fail() } - if !cmp.Equal(tg.Config, item.config) { + if tg.Config.String() != item.config.String() { t.Errorf("failed at %q", name) t.Errorf("expected %+v", item.config) t.Errorf(" got %+v", tg.Config) diff --git a/pkg/loaders/loaders_test.go b/pkg/loaders/loaders_test.go index a70791a1..0f55d64b 100644 --- a/pkg/loaders/loaders_test.go +++ b/pkg/loaders/loaders_test.go @@ -157,7 +157,22 @@ func TestGetInstancesTagsMatches(t *testing.T) { res := Diff(item.m1, item.m2) t.Logf("exp value: %+v", item.output) t.Logf("got value: %+v", res) - if !cmp.Equal(item.output, res) { + if len(item.output.Add) != len(res.Add) { + t.Fail() + } + if len(item.output.Del) != len(res.Del) { + t.Fail() + } + for k, v1 := range item.output.Add { + if v2, ok := res.Add[k]; ok { + if v1.String() != v2.String() { + t.Fail() + } + } else { + t.Fail() + } + } + if !cmp.Equal(item.output.Del, res.Del) { t.Fail() } })