Add a job, remove a job, start cron, expect nothing runs.
(t *testing.T)
| 164 | |
| 165 | // Add a job, remove a job, start cron, expect nothing runs. |
| 166 | func TestRemoveBeforeRunning(t *testing.T) { |
| 167 | wg := &sync.WaitGroup{} |
| 168 | wg.Add(1) |
| 169 | |
| 170 | cron := newWithSeconds() |
| 171 | id, _ := cron.AddFunc("* * * * * ?", func() { wg.Done() }) |
| 172 | cron.Remove(id) |
| 173 | cron.Start() |
| 174 | defer cron.Stop() |
| 175 | |
| 176 | select { |
| 177 | case <-time.After(OneSecond): |
| 178 | // Success, shouldn't run |
| 179 | case <-wait(wg): |
| 180 | t.FailNow() |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Start cron, add a job, remove it, expect it doesn't run. |
| 185 | func TestRemoveWhileRunning(t *testing.T) { |