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

Function TestAddBeforeRunning

cron_test.go:116–131  ·  cron_test.go::TestAddBeforeRunning

Add a job, start cron, expect it runs.

(t *testing.T)

Source from the content-addressed store, hash-verified

114
115// Add a job, start cron, expect it runs.
116func TestAddBeforeRunning(t *testing.T) {
117 wg := &sync.WaitGroup{}
118 wg.Add(1)
119
120 cron := newWithSeconds()
121 cron.AddFunc("* * * * * ?", func() { wg.Done() })
122 cron.Start()
123 defer cron.Stop()
124
125 // Give cron 2 seconds to run our job (which is always activated).
126 select {
127 case <-time.After(OneSecond):
128 t.Fatal("expected job runs")
129 case <-wait(wg):
130 }
131}
132
133// Start cron, add a job, expect it runs.
134func TestAddWhileRunning(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected