Start cron, add a job, remove it, expect it doesn't run.
(t *testing.T)
| 183 | |
| 184 | // Start cron, add a job, remove it, expect it doesn't run. |
| 185 | func TestRemoveWhileRunning(t *testing.T) { |
| 186 | wg := &sync.WaitGroup{} |
| 187 | wg.Add(1) |
| 188 | |
| 189 | cron := newWithSeconds() |
| 190 | cron.Start() |
| 191 | defer cron.Stop() |
| 192 | id, _ := cron.AddFunc("* * * * * ?", func() { wg.Done() }) |
| 193 | cron.Remove(id) |
| 194 | |
| 195 | select { |
| 196 | case <-time.After(OneSecond): |
| 197 | case <-wait(wg): |
| 198 | t.FailNow() |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | // Test timing with Entries. |
| 203 | func TestSnapshotEntries(t *testing.T) { |