(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func 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 | |
| 94 | func TestRecoverWithConfig(t *testing.T) { |
| 95 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…