MCPcopy Index your code
hub / github.com/codnect/chrono / TestSimpleTaskExecutor_ScheduleAtFixedRate

Function TestSimpleTaskExecutor_ScheduleAtFixedRate

executor_test.go:98–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestSimpleTaskExecutor_ScheduleAtFixedRate(t *testing.T) {
99 executor := NewSimpleTaskExecutor(NewDefaultTaskRunner())
100
101 var counter int32
102
103 task, err := executor.ScheduleAtFixedRate(func(ctx context.Context) {
104 atomic.AddInt32(&counter, 1)
105 }, 0, 200*time.Millisecond)
106
107 assert.Nil(t, err)
108
109 <-time.After(2*time.Second - 50*time.Millisecond)
110 task.Cancel()
111 assert.True(t, counter >= 1 && counter <= 10,
112 "number of scheduled task execution must be between 5 and 10, actual: %d", counter)
113}
114
115func TestSimpleTaskExecutor_ScheduleAtFixedRateWithInitialDelay(t *testing.T) {
116 executor := NewSimpleTaskExecutor(NewDefaultTaskRunner())

Callers

nothing calls this directly

Calls 4

ScheduleAtFixedRateMethod · 0.95
NewSimpleTaskExecutorFunction · 0.85
NewDefaultTaskRunnerFunction · 0.85
CancelMethod · 0.65

Tested by

no test coverage detected