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

Function TestSimpleTaskExecutor_Shutdown

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

Source from the content-addressed store, hash-verified

131}
132
133func TestSimpleTaskExecutor_Shutdown(t *testing.T) {
134 executor := NewSimpleTaskExecutor(NewDefaultTaskRunner())
135
136 var counter int32
137
138 executor.ScheduleAtFixedRate(func(ctx context.Context) {
139 atomic.AddInt32(&counter, 1)
140 <-time.After(500 * time.Millisecond)
141 }, 1*time.Second, 200*time.Millisecond)
142
143 <-time.After(2 * time.Second)
144 executor.Shutdown()
145
146 expected := counter
147 <-time.After(3 * time.Second)
148
149 assert.True(t, executor.IsShutdown())
150 assert.Equal(t, expected, counter,
151 "after shutdown, previously scheduled tasks should not be rescheduled", counter)
152}
153
154func TestSimpleTaskExecutor_NoNewTaskShouldBeAccepted_AfterShutdown(t *testing.T) {
155 executor := NewSimpleTaskExecutor(NewDefaultTaskRunner())

Callers

nothing calls this directly

Calls 5

ScheduleAtFixedRateMethod · 0.95
ShutdownMethod · 0.95
IsShutdownMethod · 0.95
NewSimpleTaskExecutorFunction · 0.85
NewDefaultTaskRunnerFunction · 0.85

Tested by

no test coverage detected