MCPcopy Create free account
hub / github.com/codnect/chrono / TestSimpleTaskScheduler_Shutdown

Function TestSimpleTaskScheduler_Shutdown

scheduler_test.go:290–311  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

288}
289
290func TestSimpleTaskScheduler_Shutdown(t *testing.T) {
291 scheduler := NewSimpleTaskScheduler(NewDefaultTaskExecutor())
292
293 var counter int32
294
295 _, err := scheduler.ScheduleAtFixedRate(func(ctx context.Context) {
296 atomic.AddInt32(&counter, 1)
297 <-time.After(500 * time.Millisecond)
298 }, 1*time.Second)
299
300 assert.Nil(t, err)
301
302 <-time.After(2 * time.Second)
303 scheduler.Shutdown()
304
305 expected := counter
306 <-time.After(3 * time.Second)
307
308 assert.True(t, scheduler.IsShutdown())
309 assert.Equal(t, expected, counter,
310 "after shutdown, previously scheduled tasks should not be rescheduled", counter)
311}

Callers

nothing calls this directly

Calls 5

ScheduleAtFixedRateMethod · 0.95
ShutdownMethod · 0.95
IsShutdownMethod · 0.95
NewSimpleTaskSchedulerFunction · 0.85
NewDefaultTaskExecutorFunction · 0.85

Tested by

no test coverage detected