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

Function TestFuncPanicRecovery

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

Source from the content-addressed store, hash-verified

39}
40
41func TestFuncPanicRecovery(t *testing.T) {
42 var buf syncWriter
43 cron := New(WithParser(secondParser),
44 WithChain(Recover(newBufLogger(&buf))))
45 cron.Start()
46 defer cron.Stop()
47 cron.AddFunc("* * * * * ?", func() {
48 panic("YOLO")
49 })
50
51 select {
52 case <-time.After(OneSecond):
53 if !strings.Contains(buf.String(), "YOLO") {
54 t.Error("expected a panic to be logged, got none")
55 }
56 return
57 }
58}
59
60type DummyJob struct{}
61

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
AddFuncMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected