If SkipFirst is passed, the given task is only executed at the second round.
(t *testing.T)
| 85 | |
| 86 | // If SkipFirst is passed, the given task is only executed at the second round. |
| 87 | func TestTask_SkipFirst(t *testing.T) { |
| 88 | i := 0 |
| 89 | f := func(context.Context) { |
| 90 | i++ |
| 91 | } |
| 92 | |
| 93 | defer startTask(t, f, task.Every(250*time.Millisecond, task.SkipFirst))() //nolint:revive |
| 94 | time.Sleep(400 * time.Millisecond) |
| 95 | assert.Equal(t, 1, i) // The function got executed only once, not twice. |
| 96 | } |
| 97 | |
| 98 | // Create a new task function that sends a notification to a channel every time |
| 99 | // it's run. |