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

Function TestTask_ScheduleTemporaryError

internal/server/task/task_test.go:67–84  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
67func 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.
87func TestTask_SkipFirst(t *testing.T) {

Callers

nothing calls this directly

Calls 2

newFuncFunction · 0.85
startTaskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…