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

Function TestMiddlewareNoMethodDisabled

middleware_test.go:118–157  ·  middleware_test.go::TestMiddlewareNoMethodDisabled
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestMiddlewareNoMethodDisabled(t *testing.T) {
119 signature := ""
120 router := New()
121
122 // NoMethod disabled
123 router.HandleMethodNotAllowed = false
124
125 router.Use(func(c *Context) {
126 signature += "A"
127 c.Next()
128 signature += "B"
129 })
130 router.Use(func(c *Context) {
131 signature += "C"
132 c.Next()
133 signature += "D"
134 })
135 router.NoMethod(func(c *Context) {
136 signature += "E"
137 c.Next()
138 signature += "F"
139 }, func(c *Context) {
140 signature += "G"
141 c.Next()
142 signature += "H"
143 })
144 router.NoRoute(func(c *Context) {
145 signature += " X "
146 })
147 router.POST("/", func(c *Context) {
148 signature += " XX "
149 })
150
151 // RUN
152 w := PerformRequest(router, http.MethodGet, "/")
153
154 // TEST
155 assert.Equal(t, http.StatusNotFound, w.Code)
156 assert.Equal(t, "AC X DB", signature)
157}
158
159func TestMiddlewareAbort(t *testing.T) {
160 signature := ""

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
PerformRequestFunction · 0.85
NextMethod · 0.80
NoMethodMethod · 0.80
NoRouteMethod · 0.80
UseMethod · 0.65
POSTMethod · 0.65

Tested by

no test coverage detected