From 0d695274943e0291ef69840ddc3b5a2a84f54a96 Mon Sep 17 00:00:00 2001 From: Karthik Bhat Date: Mon, 21 Oct 2024 14:39:47 +0530 Subject: [PATCH] Add new test to ignore last transition time even if set --- util/conditions/setter_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/util/conditions/setter_test.go b/util/conditions/setter_test.go index 5eb15f587f30..467864e65433 100644 --- a/util/conditions/setter_test.go +++ b/util/conditions/setter_test.go @@ -158,6 +158,9 @@ func TestSetLastTransitionTime(t *testing.T) { fooWithBarMessage := FalseCondition("foo", "reason foo", clusterv1.ConditionSeverityInfo, "message bar") fooWithLastTransitionTime := FalseCondition("foo", "reason foo", clusterv1.ConditionSeverityInfo, "message foo") fooWithLastTransitionTime.LastTransitionTime = x + fooWithLastTransitionTimeWithBarMessage := FalseCondition("foo", "reason foo", clusterv1.ConditionSeverityInfo, "message bar") + fooWithLastTransitionTimeWithBarMessage.LastTransitionTime = y + fooWithAnotherState := TrueCondition("foo") fooWithAnotherStateWithLastTransitionTime := TrueCondition("foo") fooWithAnotherStateWithLastTransitionTime.LastTransitionTime = y @@ -216,6 +219,14 @@ func TestSetLastTransitionTime(t *testing.T) { g.Expect(lastTransitionTime).To(Equal(x)) }, }, + { + name: "Set a condition that already exists, with different state but same Status should ignore the last transition even if defined", + to: setterWithConditions(fooWithLastTransitionTime), + new: fooWithLastTransitionTimeWithBarMessage, + LastTransitionTimeCheck: func(g *WithT, lastTransitionTime metav1.Time) { + g.Expect(lastTransitionTime).To(Equal(x)) + }, + }, } for _, tt := range tests {