MCPcopy
hub / github.com/labstack/echo / TestRecoverErrAbortHandler

Function TestRecoverErrAbortHandler

middleware/recover_test.go:67–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestRecoverErrAbortHandler(t *testing.T) {
68 e := echo.New()
69 req := httptest.NewRequest(http.MethodGet, "/", nil)
70 rec := httptest.NewRecorder()
71 c := e.NewContext(req, rec)
72 h := Recover()(func(c *echo.Context) error {
73 panic(http.ErrAbortHandler)
74 })
75 defer func() {
76 r := recover()
77 if r == nil {
78 assert.Fail(t, "expecting `http.ErrAbortHandler`, got `nil`")
79 } else {
80 if err, ok := r.(error); ok {
81 assert.ErrorIs(t, err, http.ErrAbortHandler)
82 } else {
83 assert.Fail(t, "not of error type")
84 }
85 }
86 }()
87
88 hErr := h(c)
89
90 assert.Equal(t, http.StatusInternalServerError, rec.Code)
91 assert.NotContains(t, hErr.Error(), "PANIC RECOVER")
92}
93
94func TestRecoverWithConfig(t *testing.T) {
95 var testCases = []struct {

Callers

nothing calls this directly

Calls 3

RecoverFunction · 0.85
NewContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…