Test for #34. Adding a job after calling start results in multiple job invocations
(t *testing.T)
| 149 | |
| 150 | // Test for #34. Adding a job after calling start results in multiple job invocations |
| 151 | func TestAddWhileRunningWithDelay(t *testing.T) { |
| 152 | cron := newWithSeconds() |
| 153 | cron.Start() |
| 154 | defer cron.Stop() |
| 155 | time.Sleep(5 * time.Second) |
| 156 | var calls int64 |
| 157 | cron.AddFunc("* * * * * *", func() { atomic.AddInt64(&calls, 1) }) |
| 158 | |
| 159 | <-time.After(OneSecond) |
| 160 | if atomic.LoadInt64(&calls) != 1 { |
| 161 | t.Errorf("called %d times, expected 1\n", calls) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // Add a job, remove a job, start cron, expect nothing runs. |
| 166 | func TestRemoveBeforeRunning(t *testing.T) { |
nothing calls this directly
no test coverage detected