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

Function TestMiddlewareFailHandlersChain

middleware_test.go:208–227  ·  middleware_test.go::TestMiddlewareFailHandlersChain

TestMiddlewareFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as as well as Abort

(t *testing.T)

Source from the content-addressed store, hash-verified

206// TestMiddlewareFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as
207// as well as Abort
208func 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
229func TestMiddlewareWrite(t *testing.T) {
230 router := New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
PerformRequestFunction · 0.85
AbortWithErrorMethod · 0.80
NextMethod · 0.80
UseMethod · 0.65

Tested by

no test coverage detected