(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func 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 | |
| 59 | func TestCustomHandleError(t *testing.T) { |
| 60 | old := ErrorHandlers |
nothing calls this directly
no test coverage detected