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

Function TestBlockingRun

cron_test.go:384–406  ·  cron_test.go::TestBlockingRun

Test blocking run method behaves as Start()

(t *testing.T)

Source from the content-addressed store, hash-verified

382
383// Test blocking run method behaves as Start()
384func TestBlockingRun(t *testing.T) {
385 wg := &sync.WaitGroup{}
386 wg.Add(1)
387
388 cron := newWithSeconds()
389 cron.AddFunc("* * * * * ?", func() { wg.Done() })
390
391 var unblockChan = make(chan struct{})
392
393 go func() {
394 cron.Run()
395 close(unblockChan)
396 }()
397 defer cron.Stop()
398
399 select {
400 case <-time.After(OneSecond):
401 t.Error("expected job fires")
402 case <-unblockChan:
403 t.Error("expected that Run() blocks")
404 case <-wait(wg):
405 }
406}
407
408// Test that double-running is a no-op
409func TestStartNoop(t *testing.T) {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected