Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 5bd1cf3

Browse files
eapolinarioLaPetiteSouris
authored andcommitted
Fix flaky test (#563)
Signed-off-by: TungHoang <sontunghoang@gmail.com>
1 parent e52e07a commit 5bd1cf3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/scheduler_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ func TestScheduleJob(t *testing.T) {
5959
lastExecTime *time.Time
6060
assertionFunc func(t assert.TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
6161
}{
62-
{testName: "using_schedule_time", lastExecTime: &now, assertionFunc: assert.Equal},
63-
{testName: "without_schedule_time", lastExecTime: nil, assertionFunc: assert.NotEqual},
62+
{testName: "without_schedule_time", lastExecTime: nil},
63+
{testName: "using_schedule_time", lastExecTime: &now},
6464
}
6565
wg := &sync.WaitGroup{}
6666
for _, tc := range tests {
6767
t.Run(tc.testName, func(t *testing.T) {
6868
wg.Add(1)
6969
timedFuncWithSchedule := func(jobCtx context.Context, schedule models.SchedulableEntity, scheduleTime time.Time) error {
70-
tc.assertionFunc(t, now, scheduleTime)
70+
if scheduleTime.IsZero() {
71+
assert.NotEqual(t, now, scheduleTime)
72+
} else {
73+
assert.WithinDuration(t, now, scheduleTime, time.Minute*2)
74+
}
7175
wg.Done()
7276
return nil
7377
}

0 commit comments

Comments
 (0)