(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestNewDefaultTaskExecutor(t *testing.T) { |
| 12 | executor := NewDefaultTaskExecutor() |
| 13 | |
| 14 | var counter int32 |
| 15 | |
| 16 | task, err := executor.Schedule(func(ctx context.Context) { |
| 17 | atomic.AddInt32(&counter, 1) |
| 18 | }, 1*time.Second) |
| 19 | |
| 20 | assert.Nil(t, err) |
| 21 | |
| 22 | <-time.After(2 * time.Second) |
| 23 | assert.True(t, task.IsCancelled(), "scheduled task must have been cancelled") |
| 24 | assert.True(t, counter == 1, |
| 25 | "number of scheduled task execution must be 1, actual: %d", counter) |
| 26 | } |
| 27 | |
| 28 | func TestSimpleTaskExecutor_WithoutTaskRunner(t *testing.T) { |
| 29 | executor := NewSimpleTaskExecutor(nil) |
nothing calls this directly
no test coverage detected