Skip to content

Commit

Permalink
Add test skipImmediately is switched to false after reconcile
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger Kaovilai <[email protected]>
  • Loading branch information
kaovilai committed Dec 6, 2023
1 parent 6ff6023 commit 0792f77
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/controller/schedule_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ func TestReconcileOfSchedule(t *testing.T) {
require.Nil(t, client.Create(ctx, test.backup))
}

scheduleb4reconcile := &velerov1.Schedule{}
err = client.Get(ctx, types.NamespacedName{Namespace: "ns", Name: "name"}, scheduleb4reconcile)
if test.schedule != nil {
require.Nil(t, err)
}

_, err = reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: types.NamespacedName{Namespace: "ns", Name: "name"}})
require.Nil(t, err)

Expand All @@ -200,6 +206,12 @@ func TestReconcileOfSchedule(t *testing.T) {
assert.Equal(t, parseTime(test.expectedLastSkipped).Unix(), schedule.Status.LastSkipped.Unix())
}

// we expect reconcile to flip SkipImmediately to false if it's true or the server is configured to skip immediately and the schedule doesn't have it set
if scheduleb4reconcile.Spec.SkipImmediately != nil && *scheduleb4reconcile.Spec.SkipImmediately ||
test.reconcilerSkipImmediately && scheduleb4reconcile.Spec.SkipImmediately == nil {
assert.Equal(t, schedule.Spec.SkipImmediately, pointer.Bool(false))
}

backups := &velerov1.BackupList{}
require.Nil(t, client.List(ctx, backups))

Expand Down

0 comments on commit 0792f77

Please sign in to comment.