If the schedule returns an error, the task is aborted.
(t *testing.T)
| 51 | |
| 52 | // If the schedule returns an error, the task is aborted. |
| 53 | func TestTask_ScheduleError(t *testing.T) { |
| 54 | schedule := func() (time.Duration, error) { |
| 55 | return 0, errors.New("boom") |
| 56 | } |
| 57 | |
| 58 | f, _ := newFunc(t, 0) |
| 59 | defer startTask(t, f, schedule)() //nolint:revive |
| 60 | |
| 61 | // Sleep a little bit to prove that the task function does not get run. |
| 62 | time.Sleep(100 * time.Millisecond) |
| 63 | } |
| 64 | |
| 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. |