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

Function TestJobPanicRecovery

cron_test.go:66–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestJobPanicRecovery(t *testing.T) {
67 var job DummyJob
68
69 var buf syncWriter
70 cron := New(WithParser(secondParser),
71 WithChain(Recover(newBufLogger(&buf))))
72 cron.Start()
73 defer cron.Stop()
74 cron.AddJob("* * * * * ?", job)
75
76 select {
77 case <-time.After(OneSecond):
78 if !strings.Contains(buf.String(), "YOLO") {
79 t.Error("expected a panic to be logged, got none")
80 }
81 return
82 }
83}
84
85// Start and stop cron with no entries.
86func TestNoEntries(t *testing.T) {

Callers

nothing calls this directly

Calls 10

StringMethod · 0.95
NewFunction · 0.85
WithParserFunction · 0.85
WithChainFunction · 0.85
RecoverFunction · 0.85
newBufLoggerFunction · 0.85
StartMethod · 0.80
StopMethod · 0.80
AddJobMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected