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

Function TestRouteNotAllowedDisabled

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

Source from the content-addressed store, hash-verified

528}
529
530func TestRouteNotAllowedDisabled(t *testing.T) {
531 router := New()
532 router.HandleMethodNotAllowed = false
533 router.POST("/path", func(c *Context) {})
534 w := PerformRequest(router, http.MethodGet, "/path")
535 assert.Equal(t, http.StatusNotFound, w.Code)
536
537 router.NoMethod(func(c *Context) {
538 c.String(http.StatusTeapot, "responseText")
539 })
540 w = PerformRequest(router, http.MethodGet, "/path")
541 assert.Equal(t, "404 page not found", w.Body.String())
542 assert.Equal(t, http.StatusNotFound, w.Code)
543}
544
545func TestRouterNotFoundWithRemoveExtraSlash(t *testing.T) {
546 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