@@ -53,6 +53,9 @@ type testCase struct {
5353 expectedStatus * machinev1.MachineHealthCheckStatus
5454 externalRemediationMachine * unstructured.Unstructured
5555 externalRemediationTemplate * unstructured.Unstructured
56+ // setup is called immediately before the reconcile to allow time-sensitive
57+ // test cases to refresh state (e.g. LastTransitionTime) right before execution.
58+ setup func ()
5659}
5760
5861type expectedReconcile struct {
@@ -325,6 +328,9 @@ func TestReconcile(t *testing.T) {
325328 machine : machineWithNodeRecentlyUnhealthy ,
326329 node : nodeRecentlyUnhealthy ,
327330 mhc : machineHealthCheck ,
331+ setup : func () {
332+ nodeRecentlyUnhealthy .Status .Conditions [0 ].LastTransitionTime = metav1.Time {Time : time .Now ()}
333+ },
328334 expected : expectedReconcile {
329335 result : reconcile.Result {
330336 RequeueAfter : 300 * time .Second ,
@@ -488,6 +494,9 @@ func TestReconcile(t *testing.T) {
488494
489495 for _ , tc := range testCases {
490496 t .Run (tc .name , func (t * testing.T ) {
497+ if tc .setup != nil {
498+ tc .setup ()
499+ }
491500 recorder := record .NewFakeRecorder (2 )
492501 r := newFakeReconcilerWithCustomRecorder (recorder , buildRunTimeObjects (tc )... )
493502 assertBaseReconcile (t , tc , ctx , r )
0 commit comments