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

Function TestDefaultRouter_AddDuplicateRouteAllowed

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

Source from the content-addressed store, hash-verified

3172}
3173
3174func TestDefaultRouter_AddDuplicateRouteAllowed(t *testing.T) {
3175 e := New()
3176 router := NewRouter(RouterConfig{AllowOverwritingRoute: true})
3177 e.router = router
3178
3179 ri, err := router.Add(Route{Method: http.MethodGet, Path: "/info", Handler: handlerFunc, Name: "old"})
3180 assert.NoError(t, err)
3181 assert.Equal(t, ri, RouteInfo{
3182 Method: http.MethodGet,
3183 Path: "/info",
3184 Name: "old",
3185 })
3186
3187 ri, err = router.Add(Route{
3188 Method: http.MethodGet,
3189 Path: "/info",
3190 Handler: func(c *Context) error {
3191 return c.String(http.StatusTeapot, "NEW")
3192 },
3193 Name: "new",
3194 })
3195 assert.NoError(t, err)
3196 assert.Equal(t, ri, RouteInfo{
3197 Method: http.MethodGet,
3198 Path: "/info",
3199 Name: "new",
3200 })
3201
3202 routes := router.Routes()
3203 assert.Len(t, routes, 1)
3204 assert.Equal(t, "new", routes[0].Name)
3205
3206 status, body := request(http.MethodGet, "/info", e)
3207 assert.Equal(t, http.StatusTeapot, status)
3208 assert.Equal(t, "NEW", body)
3209}
3210
3211func TestDefaultRouter_UseEscapedPathForRouting(t *testing.T) {
3212 var testCases = []struct {

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…