(t *testing.T)
| 60 | } |
| 61 | |
| 62 | func TestSimpleTaskExecutor_ScheduleWithFixedDelay(t *testing.T) { |
| 63 | executor := NewSimpleTaskExecutor(NewDefaultTaskRunner()) |
| 64 | |
| 65 | var counter int32 |
| 66 | |
| 67 | task, err := executor.ScheduleWithFixedDelay(func(ctx context.Context) { |
| 68 | atomic.AddInt32(&counter, 1) |
| 69 | <-time.After(500 * time.Millisecond) |
| 70 | }, 0, 200*time.Millisecond) |
| 71 | |
| 72 | assert.Nil(t, err) |
| 73 | |
| 74 | <-time.After(1*time.Second + 500*time.Millisecond) |
| 75 | task.Cancel() |
| 76 | assert.True(t, counter >= 1 && counter <= 3, |
| 77 | "number of scheduled task execution must be between 1 and 3, actual: %d", counter) |
| 78 | } |
| 79 | |
| 80 | func TestSimpleTaskExecutor_ScheduleWithFixedDelayWithInitialDelay(t *testing.T) { |
| 81 | executor := NewSimpleTaskExecutor(NewDefaultTaskRunner()) |
nothing calls this directly
no test coverage detected