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

Function TestSnapshotEntries

cron_test.go:203–224  ·  view source on GitHub ↗

Test timing with Entries.

(t *testing.T)

Source from the content-addressed store, hash-verified

201
202// Test timing with Entries.
203func TestSnapshotEntries(t *testing.T) {
204 wg := &sync.WaitGroup{}
205 wg.Add(1)
206
207 cron := New()
208 cron.AddFunc("@every 2s", func() { wg.Done() })
209 cron.Start()
210 defer cron.Stop()
211
212 // Cron should fire in 2 seconds. After 1 second, call Entries.
213 select {
214 case <-time.After(OneSecond):
215 cron.Entries()
216 }
217
218 // Even though Entries was called, the cron should fire at the 2 second mark.
219 select {
220 case <-time.After(OneSecond):
221 t.Error("expected job runs at 2 second mark")
222 case <-wait(wg):
223 }
224}
225
226// Test that the entries are correctly sorted.
227// Add a bunch of long-in-the-future entries, and an immediate entry, and ensure

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
waitFunction · 0.85
AddFuncMethod · 0.80
DoneMethod · 0.80
StartMethod · 0.80
StopMethod · 0.80
EntriesMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected