Add a job, start cron, expect it runs.
(t *testing.T)
| 114 | |
| 115 | // Add a job, start cron, expect it runs. |
| 116 | func TestAddBeforeRunning(t *testing.T) { |
| 117 | wg := &sync.WaitGroup{} |
| 118 | wg.Add(1) |
| 119 | |
| 120 | cron := newWithSeconds() |
| 121 | cron.AddFunc("* * * * * ?", func() { wg.Done() }) |
| 122 | cron.Start() |
| 123 | defer cron.Stop() |
| 124 | |
| 125 | // Give cron 2 seconds to run our job (which is always activated). |
| 126 | select { |
| 127 | case <-time.After(OneSecond): |
| 128 | t.Fatal("expected job runs") |
| 129 | case <-wait(wg): |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Start cron, add a job, expect it runs. |
| 134 | func TestAddWhileRunning(t *testing.T) { |