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

Function TestRouteNotAllowedEnabled

routes_test.go:493–506  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

491}
492
493func TestRouteNotAllowedEnabled(t *testing.T) {
494 router := New()
495 router.HandleMethodNotAllowed = true
496 router.POST("/path", func(c *Context) {})
497 w := PerformRequest(router, http.MethodGet, "/path")
498 assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
499
500 router.NoMethod(func(c *Context) {
501 c.String(http.StatusTeapot, "responseText")
502 })
503 w = PerformRequest(router, http.MethodGet, "/path")
504 assert.Equal(t, "responseText", w.Body.String())
505 assert.Equal(t, http.StatusTeapot, w.Code)
506}
507
508func TestRouteNotAllowedEnabled2(t *testing.T) {
509 router := New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
PerformRequestFunction · 0.85
NoMethodMethod · 0.80
POSTMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected