TestMiddlewareFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as as well as Abort
(t *testing.T)
| 206 | // TestMiddlewareFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as |
| 207 | // as well as Abort |
| 208 | func TestMiddlewareFailHandlersChain(t *testing.T) { |
| 209 | // SETUP |
| 210 | signature := "" |
| 211 | router := New() |
| 212 | router.Use(func(context *Context) { |
| 213 | signature += "A" |
| 214 | context.AbortWithError(http.StatusInternalServerError, errors.New("foo")) //nolint: errcheck |
| 215 | }) |
| 216 | router.Use(func(context *Context) { |
| 217 | signature += "B" |
| 218 | context.Next() |
| 219 | signature += "C" |
| 220 | }) |
| 221 | // RUN |
| 222 | w := PerformRequest(router, http.MethodGet, "/") |
| 223 | |
| 224 | // TEST |
| 225 | assert.Equal(t, http.StatusInternalServerError, w.Code) |
| 226 | assert.Equal(t, "A", signature) |
| 227 | } |
| 228 | |
| 229 | func TestMiddlewareWrite(t *testing.T) { |
| 230 | router := New() |
nothing calls this directly
no test coverage detected