(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func TestMiddlewareAbort(t *testing.T) { |
| 160 | signature := "" |
| 161 | router := New() |
| 162 | router.Use(func(c *Context) { |
| 163 | signature += "A" |
| 164 | }) |
| 165 | router.Use(func(c *Context) { |
| 166 | signature += "C" |
| 167 | c.AbortWithStatus(http.StatusUnauthorized) |
| 168 | c.Next() |
| 169 | signature += "D" |
| 170 | }) |
| 171 | router.GET("/", func(c *Context) { |
| 172 | signature += " X " |
| 173 | c.Next() |
| 174 | signature += " XX " |
| 175 | }) |
| 176 | |
| 177 | // RUN |
| 178 | w := PerformRequest(router, http.MethodGet, "/") |
| 179 | |
| 180 | // TEST |
| 181 | assert.Equal(t, http.StatusUnauthorized, w.Code) |
| 182 | assert.Equal(t, "ACD", signature) |
| 183 | } |
| 184 | |
| 185 | func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) { |
| 186 | signature := "" |
nothing calls this directly
no test coverage detected