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

Function TestRunningJobTwice

cron_test.go:255–272  ·  view source on GitHub ↗

Test running the same job twice.

(t *testing.T)

Source from the content-addressed store, hash-verified

253
254// Test running the same job twice.
255func TestRunningJobTwice(t *testing.T) {
256 wg := &sync.WaitGroup{}
257 wg.Add(2)
258
259 cron := newWithSeconds()
260 cron.AddFunc("0 0 0 1 1 ?", func() {})
261 cron.AddFunc("0 0 0 31 12 ?", func() {})
262 cron.AddFunc("* * * * * ?", func() { wg.Done() })
263
264 cron.Start()
265 defer cron.Stop()
266
267 select {
268 case <-time.After(2 * OneSecond):
269 t.Error("expected job fires 2 times")
270 case <-wait(wg):
271 }
272}
273
274func TestRunningMultipleSchedules(t *testing.T) {
275 wg := &sync.WaitGroup{}

Callers

nothing calls this directly

Calls 7

newWithSecondsFunction · 0.85
waitFunction · 0.85
AddFuncMethod · 0.80
DoneMethod · 0.80
StartMethod · 0.80
StopMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected