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

Function TestMultipleEntries

cron_test.go:230–252  ·  view source on GitHub ↗

Test that the entries are correctly sorted. Add a bunch of long-in-the-future entries, and an immediate entry, and ensure that the immediate entry runs immediately. Also: Test that multiple jobs run in the same instant.

(t *testing.T)

Source from the content-addressed store, hash-verified

228// that the immediate entry runs immediately.
229// Also: Test that multiple jobs run in the same instant.
230func TestMultipleEntries(t *testing.T) {
231 wg := &sync.WaitGroup{}
232 wg.Add(2)
233
234 cron := newWithSeconds()
235 cron.AddFunc("0 0 0 1 1 ?", func() {})
236 cron.AddFunc("* * * * * ?", func() { wg.Done() })
237 id1, _ := cron.AddFunc("* * * * * ?", func() { t.Fatal() })
238 id2, _ := cron.AddFunc("* * * * * ?", func() { t.Fatal() })
239 cron.AddFunc("0 0 0 31 12 ?", func() {})
240 cron.AddFunc("* * * * * ?", func() { wg.Done() })
241
242 cron.Remove(id1)
243 cron.Start()
244 cron.Remove(id2)
245 defer cron.Stop()
246
247 select {
248 case <-time.After(OneSecond):
249 t.Error("expected job run in proper order")
250 case <-wait(wg):
251 }
252}
253
254// Test running the same job twice.
255func TestRunningJobTwice(t *testing.T) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected