MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestCustomHandleCrash

Function TestCustomHandleCrash

pkg/util/runtime/runtime_test.go:36–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestCustomHandleCrash(t *testing.T) {
37 old := PanicHandlers
38 defer func() { PanicHandlers = old }()
39 var result interface{}
40 PanicHandlers = []func(interface{}){
41 func(r interface{}) {
42 result = r
43 },
44 }
45 func() {
46 defer func() {
47 if x := recover(); x == nil {
48 t.Errorf("Expected a panic to recover from")
49 }
50 }()
51 defer HandleCrash()
52 panic("test")
53 }()
54 if result != "test" {
55 t.Errorf("did not receive custom handler")
56 }
57}
58
59func TestCustomHandleError(t *testing.T) {
60 old := ErrorHandlers

Callers

nothing calls this directly

Calls 2

HandleCrashFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected