Start cron, add a job, expect it runs.
(t *testing.T)
| 132 | |
| 133 | // Start cron, add a job, expect it runs. |
| 134 | func TestAddWhileRunning(t *testing.T) { |
| 135 | wg := &sync.WaitGroup{} |
| 136 | wg.Add(1) |
| 137 | |
| 138 | cron := newWithSeconds() |
| 139 | cron.Start() |
| 140 | defer cron.Stop() |
| 141 | cron.AddFunc("* * * * * ?", func() { wg.Done() }) |
| 142 | |
| 143 | select { |
| 144 | case <-time.After(OneSecond): |
| 145 | t.Fatal("expected job runs") |
| 146 | case <-wait(wg): |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // Test for #34. Adding a job after calling start results in multiple job invocations |
| 151 | func TestAddWhileRunningWithDelay(t *testing.T) { |