(t *testing.T)
| 288 | } |
| 289 | |
| 290 | func 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 | } |
nothing calls this directly
no test coverage detected