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

Function TestAddWhileRunning

cron_test.go:134–148  ·  cron_test.go::TestAddWhileRunning

Start cron, add a job, expect it runs.

(t *testing.T)

Source from the content-addressed store, hash-verified

132
133// Start cron, add a job, expect it runs.
134func TestAddWhileRunning(t *testing.T) {
135 wg := &sync.WaitGroup{}
136 wg.Add(1)
137
138 cron := newWithSeconds()
139 cron.Start()
140 defer cron.Stop()
141 cron.AddFunc("* * * * * ?", func() { wg.Done() })
142
143 select {
144 case <-time.After(OneSecond):
145 t.Fatal("expected job runs")
146 case <-wait(wg):
147 }
148}
149
150// Test for #34. Adding a job after calling start results in multiple job invocations
151func TestAddWhileRunningWithDelay(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected