| 3054 | } |
| 3055 | |
| 3056 | func 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 |
| 3083 | func TestDefaultRouter_UnescapePathParamValues(t *testing.T) { |