Test blocking run method behaves as Start()
(t *testing.T)
| 382 | |
| 383 | // Test blocking run method behaves as Start() |
| 384 | func TestBlockingRun(t *testing.T) { |
| 385 | wg := &sync.WaitGroup{} |
| 386 | wg.Add(1) |
| 387 | |
| 388 | cron := newWithSeconds() |
| 389 | cron.AddFunc("* * * * * ?", func() { wg.Done() }) |
| 390 | |
| 391 | var unblockChan = make(chan struct{}) |
| 392 | |
| 393 | go func() { |
| 394 | cron.Run() |
| 395 | close(unblockChan) |
| 396 | }() |
| 397 | defer cron.Stop() |
| 398 | |
| 399 | select { |
| 400 | case <-time.After(OneSecond): |
| 401 | t.Error("expected job fires") |
| 402 | case <-unblockChan: |
| 403 | t.Error("expected that Run() blocks") |
| 404 | case <-wait(wg): |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Test that double-running is a no-op |
| 409 | func TestStartNoop(t *testing.T) { |