Skip to content

Commit

Permalink
Add new test to ignore last transition time even if set
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Oct 21, 2024
1 parent f62cbad commit 0d69527
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions util/conditions/setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0d69527

Please sign in to comment.