Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type testCase struct {
expectedStatus *machinev1.MachineHealthCheckStatus
externalRemediationMachine *unstructured.Unstructured
externalRemediationTemplate *unstructured.Unstructured
// setup is called immediately before the reconcile to allow time-sensitive
// test cases to refresh state (e.g. LastTransitionTime) right before execution.
setup func()
}

type expectedReconcile struct {
Expand Down Expand Up @@ -325,6 +328,9 @@ func TestReconcile(t *testing.T) {
machine: machineWithNodeRecentlyUnhealthy,
node: nodeRecentlyUnhealthy,
mhc: machineHealthCheck,
setup: func() {
nodeRecentlyUnhealthy.Status.Conditions[0].LastTransitionTime = metav1.Time{Time: time.Now()}
},
expected: expectedReconcile{
result: reconcile.Result{
RequeueAfter: 300 * time.Second,
Expand Down Expand Up @@ -488,6 +494,9 @@ func TestReconcile(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.setup != nil {
tc.setup()
}
recorder := record.NewFakeRecorder(2)
r := newFakeReconcilerWithCustomRecorder(recorder, buildRunTimeObjects(tc)...)
assertBaseReconcile(t, tc, ctx, r)
Expand Down