From 63f992c9d59c834e7bc6a555734a798e079f9805 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 3 Sep 2024 14:20:34 +0200 Subject: [PATCH] fix unit tests --- util/conditions/experimental/getter_test.go | 18 +++++++++--------- util/conditions/experimental/setter_test.go | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/util/conditions/experimental/getter_test.go b/util/conditions/experimental/getter_test.go index 53e1d47ca449..dac4680a91dd 100644 --- a/util/conditions/experimental/getter_test.go +++ b/util/conditions/experimental/getter_test.go @@ -152,7 +152,7 @@ func TestGetAll(t *testing.T) { Status: builder.Phase0ObjStatus{ Conditions: clusterv1.Conditions{ { - Type: "fooCondition", + Type: "barCondition", Status: corev1.ConditionTrue, LastTransitionTime: now, }, @@ -184,14 +184,14 @@ func TestGetAll(t *testing.T) { got, err := GetAll(foo) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) fooUnstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(foo) g.Expect(err).NotTo(HaveOccurred()) got, err = GetAll(&unstructured.Unstructured{Object: fooUnstructured}) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) }) t.Run("v1beta1 object with both legacy and experimental conditions", func(t *testing.T) { @@ -231,14 +231,14 @@ func TestGetAll(t *testing.T) { got, err := GetAll(foo) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) fooUnstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(foo) g.Expect(err).NotTo(HaveOccurred()) got, err = GetAll(&unstructured.Unstructured{Object: fooUnstructured}) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) }) t.Run("v1beta2 object with conditions and backward compatible conditions", func(t *testing.T) { @@ -274,14 +274,14 @@ func TestGetAll(t *testing.T) { got, err := GetAll(foo) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) fooUnstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(foo) g.Expect(err).NotTo(HaveOccurred()) got, err = GetAll(&unstructured.Unstructured{Object: fooUnstructured}) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) }) t.Run("v1beta2 object with conditions (end state)", func(t *testing.T) { @@ -308,13 +308,13 @@ func TestGetAll(t *testing.T) { got, err := GetAll(foo) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) fooUnstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(foo) g.Expect(err).NotTo(HaveOccurred()) got, err = GetAll(&unstructured.Unstructured{Object: fooUnstructured}) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(expect), cmp.Diff(got, expect)) + g.Expect(got).To(MatchConditions(expect), cmp.Diff(got, expect)) }) } diff --git a/util/conditions/experimental/setter_test.go b/util/conditions/experimental/setter_test.go index 7c9543110a38..0793c5192239 100644 --- a/util/conditions/experimental/setter_test.go +++ b/util/conditions/experimental/setter_test.go @@ -183,7 +183,7 @@ func TestSetAll(t *testing.T) { got, err := GetAll(fooFromUnstructured) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(conditions), cmp.Diff(got, conditions)) + g.Expect(got).To(MatchConditions(conditions), cmp.Diff(got, conditions)) }) t.Run("v1beta2 object with conditions and backward compatible conditions", func(t *testing.T) { @@ -206,7 +206,7 @@ func TestSetAll(t *testing.T) { conditions := cloneConditions() err := SetAll(foo, conditions) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(foo.Status.Conditions).To(Equal(conditions), cmp.Diff(foo.Status.Conditions, conditions)) + g.Expect(foo.Status.Conditions).To(MatchConditions(conditions), cmp.Diff(foo.Status.Conditions, conditions)) }) t.Run("v1beta2 object with conditions and backward compatible conditions / Unstructured", func(t *testing.T) { @@ -240,7 +240,7 @@ func TestSetAll(t *testing.T) { got, err := GetAll(fooFromUnstructured) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(conditions), cmp.Diff(got, conditions)) + g.Expect(got).To(MatchConditions(conditions), cmp.Diff(got, conditions)) }) t.Run("v1beta2 object with conditions (end state)", func(t *testing.T) { @@ -279,6 +279,6 @@ func TestSetAll(t *testing.T) { got, err := GetAll(fooFromUnstructured) g.Expect(err).NotTo(HaveOccurred()) - g.Expect(got).To(Equal(conditions), cmp.Diff(got, conditions)) + g.Expect(got).To(MatchConditions(conditions), cmp.Diff(got, conditions)) }) }