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

Function TestDefaultRouter_AddDuplicateRouteNotAllowed

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

Source from the content-addressed store, hash-verified

3054}
3055
3056func TestDefaultRouter_AddDuplicateRouteNotAllowed(t *testing.T) {
3057 e := New()
3058 router := NewRouter(RouterConfig{})
3059 e.router = router
3060
3061 ri, err := router.Add(Route{
3062 Method: http.MethodGet,
3063 Path: "/info",
3064 Handler: func(c *Context) error {
3065 return c.String(http.StatusTeapot, "OLD")
3066 },
3067 Name: "old",
3068 })
3069 assert.NoError(t, err)
3070 assert.NotNil(t, ri)
3071
3072 ri, err = router.Add(Route{Method: http.MethodGet, Path: "/info", Handler: handlerFunc, Name: "new"})
3073 assert.Equal(t, RouteInfo{}, ri)
3074 assert.EqualError(t, err, "GET /info: adding duplicate route (same method+path) is not allowed")
3075 assert.Len(t, router.Routes(), 1)
3076
3077 status, body := request(http.MethodGet, "/info", e)
3078 assert.Equal(t, http.StatusTeapot, status)
3079 assert.Equal(t, "OLD", body)
3080}
3081
3082// See issue #1531, #1258 - there are cases when path parameter need to be unescaped
3083func TestDefaultRouter_UnescapePathParamValues(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
RoutesMethod · 0.95
NewFunction · 0.85
NewRouterFunction · 0.85
requestFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…