(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func 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 | |
| 115 | func TestSimpleTaskExecutor_ScheduleAtFixedRateWithInitialDelay(t *testing.T) { |
| 116 | executor := NewSimpleTaskExecutor(NewDefaultTaskRunner()) |
nothing calls this directly
no test coverage detected