MCPcopy
hub / github.com/labstack/echo / TestRouterAllowHeaderForAnyOtherMethodType

Function TestRouterAllowHeaderForAnyOtherMethodType

router_test.go:805–827  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

803}
804
805func TestRouterAllowHeaderForAnyOtherMethodType(t *testing.T) {
806 e := New()
807 r := e.router
808
809 _, err := r.Add(Route{Method: http.MethodGet, Path: "/users", Handler: handlerFunc})
810 assert.NoError(t, err)
811 _, err = r.Add(Route{Method: "COPY", Path: "/users", Handler: handlerFunc})
812 assert.NoError(t, err)
813 _, err = r.Add(Route{Method: "LOCK", Path: "/users", Handler: handlerFunc})
814 assert.NoError(t, err)
815
816 req := httptest.NewRequest("TEST", "/users", nil)
817 rec := httptest.NewRecorder()
818
819 //r.Find("TEST", "/users", c)
820 c := e.NewContext(req, rec)
821
822 handler := e.router.Route(c)
823 err = handler(c)
824
825 assert.EqualError(t, err, "Method Not Allowed")
826 assert.ElementsMatch(t, []string{"COPY", "GET", "LOCK", "OPTIONS"}, strings.Split(c.Response().Header().Get(HeaderAllow), ", "))
827}
828
829func TestMethodNotAllowedAndNotFound(t *testing.T) {
830 e := New()

Callers

nothing calls this directly

Calls 7

ResponseMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
AddMethod · 0.65
RouteMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…