From eaba99b92e61f3a735b9eb7ae1c8f0a30903ba77 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Wed, 6 Dec 2023 14:54:40 +0700 Subject: [PATCH] Add test skipImmediately is switched to false after reconcile Signed-off-by: Tiger Kaovilai --- pkg/controller/schedule_controller_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/controller/schedule_controller_test.go b/pkg/controller/schedule_controller_test.go index bcc0ff568..b2150fc49 100644 --- a/pkg/controller/schedule_controller_test.go +++ b/pkg/controller/schedule_controller_test.go @@ -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) @@ -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))