If the schedule returns an error, but its interval is positive, the task will try again to invoke the schedule function after that interval.
(t *testing.T)
| 65 | // If the schedule returns an error, but its interval is positive, the task will |
| 66 | // try again to invoke the schedule function after that interval. |
| 67 | func TestTask_ScheduleTemporaryError(t *testing.T) { |
| 68 | errored := false |
| 69 | schedule := func() (time.Duration, error) { |
| 70 | if !errored { |
| 71 | errored = true |
| 72 | return time.Millisecond, errors.New("boom") |
| 73 | } |
| 74 | |
| 75 | return time.Second, nil |
| 76 | } |
| 77 | |
| 78 | f, wait := newFunc(t, 1) |
| 79 | defer startTask(t, f, schedule)() //nolint:revive |
| 80 | |
| 81 | // The task gets executed since the schedule error is temporary and gets |
| 82 | // resolved. |
| 83 | wait(50 * time.Millisecond) |
| 84 | } |
| 85 | |
| 86 | // If SkipFirst is passed, the given task is only executed at the second round. |
| 87 | func TestTask_SkipFirst(t *testing.T) { |