MCPcopy
hub / github.com/robfig/cron / TestRemoveBeforeRunning

Function TestRemoveBeforeRunning

cron_test.go:166–182  ·  cron_test.go::TestRemoveBeforeRunning

Add a job, remove a job, start cron, expect nothing runs.

(t *testing.T)

Source from the content-addressed store, hash-verified

164
165// Add a job, remove a job, start cron, expect nothing runs.
166func 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.
185func TestRemoveWhileRunning(t *testing.T) {

Callers

nothing calls this directly

Calls 7

newWithSecondsFunction · 0.85
waitFunction · 0.85
AddFuncMethod · 0.80
DoneMethod · 0.80
RemoveMethod · 0.80
StartMethod · 0.80
StopMethod · 0.80

Tested by

no test coverage detected