MCPcopy
hub / github.com/lxc/incus / TestTask_SkipFirst

Function TestTask_SkipFirst

internal/server/task/task_test.go:87–96  ·  view source on GitHub ↗

If SkipFirst is passed, the given task is only executed at the second round.

(t *testing.T)

Source from the content-addressed store, hash-verified

85
86// If SkipFirst is passed, the given task is only executed at the second round.
87func 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.

Callers

nothing calls this directly

Calls 2

EveryFunction · 0.92
startTaskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…