(t *testing.T)
| 214 | } |
| 215 | |
| 216 | func TestSimpleTaskScheduler_ScheduleAtFixedRate(t *testing.T) { |
| 217 | scheduler := NewSimpleTaskScheduler(NewDefaultTaskExecutor()) |
| 218 | |
| 219 | var counter int32 |
| 220 | |
| 221 | task, err := scheduler.ScheduleAtFixedRate(func(ctx context.Context) { |
| 222 | atomic.AddInt32(&counter, 1) |
| 223 | }, 200*time.Millisecond) |
| 224 | |
| 225 | assert.Nil(t, err) |
| 226 | |
| 227 | <-time.After(1*time.Second + 950*time.Microsecond) |
| 228 | task.Cancel() |
| 229 | assert.True(t, counter >= 1 && counter <= 10, |
| 230 | "number of scheduled task execution must be between 5 and 10, actual: %d", counter) |
| 231 | } |
| 232 | |
| 233 | func TestSimpleTaskScheduler_ScheduleAtFixedRateWithStartTimeOption(t *testing.T) { |
| 234 | scheduler := NewSimpleTaskScheduler(NewDefaultTaskExecutor()) |
nothing calls this directly
no test coverage detected