Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Sep 10, 2024
1 parent caa2607 commit 63f992c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions util/conditions/experimental/getter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestGetAll(t *testing.T) {
Status: builder.Phase0ObjStatus{
Conditions: clusterv1.Conditions{
{
Type: "fooCondition",
Type: "barCondition",
Status: corev1.ConditionTrue,
LastTransitionTime: now,
},
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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))
})
}
8 changes: 4 additions & 4 deletions util/conditions/experimental/setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
})
}

0 comments on commit 63f992c

Please sign in to comment.