MCPcopy
hub / github.com/gin-gonic/gin / TestMiddlewareAbortHandlersChainAndNext

Function TestMiddlewareAbortHandlersChainAndNext

middleware_test.go:185–204  ·  middleware_test.go::TestMiddlewareAbortHandlersChainAndNext
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) {
186 signature := ""
187 router := New()
188 router.Use(func(c *Context) {
189 signature += "A"
190 c.Next()
191 c.AbortWithStatus(http.StatusGone)
192 signature += "B"
193 })
194 router.GET("/", func(c *Context) {
195 signature += "C"
196 c.Next()
197 })
198 // RUN
199 w := PerformRequest(router, http.MethodGet, "/")
200
201 // TEST
202 assert.Equal(t, http.StatusGone, w.Code)
203 assert.Equal(t, "ACB", signature)
204}
205
206// TestMiddlewareFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as
207// as well as Abort

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
PerformRequestFunction · 0.85
NextMethod · 0.80
AbortWithStatusMethod · 0.80
UseMethod · 0.65
GETMethod · 0.65

Tested by

no test coverage detected