Issue #1509
(t *testing.T)
| 1280 | |
| 1281 | // Issue #1509 |
| 1282 | func TestRouterParamStaticConflict(t *testing.T) { |
| 1283 | e := New() |
| 1284 | |
| 1285 | g := e.Group("/g") |
| 1286 | g.GET("/skills", handlerFunc) |
| 1287 | g.GET("/status", handlerFunc) |
| 1288 | g.GET("/:name", handlerFunc) |
| 1289 | |
| 1290 | var testCases = []struct { |
| 1291 | expectRoute any |
| 1292 | expectParam map[string]string |
| 1293 | whenURL string |
| 1294 | }{ |
| 1295 | { |
| 1296 | whenURL: "/g/s", |
| 1297 | expectRoute: "/g/:name", |
| 1298 | expectParam: map[string]string{"name": "s"}, |
| 1299 | }, |
| 1300 | { |
| 1301 | whenURL: "/g/status", |
| 1302 | expectRoute: "/g/status", |
| 1303 | expectParam: map[string]string{"name": ""}, |
| 1304 | }, |
| 1305 | } |
| 1306 | for _, tc := range testCases { |
| 1307 | t.Run(tc.whenURL, func(t *testing.T) { |
| 1308 | c := e.NewContext(httptest.NewRequest(http.MethodGet, tc.whenURL, nil), nil) |
| 1309 | |
| 1310 | handler := e.router.Route(c) |
| 1311 | |
| 1312 | assert.NoError(t, handler(c)) |
| 1313 | assert.Equal(t, tc.expectRoute, c.Path()) |
| 1314 | for param, expectedValue := range tc.expectParam { |
| 1315 | assert.Equal(t, expectedValue, c.pathValues.GetOr(param, "")) |
| 1316 | } |
| 1317 | checkUnusedParamValues(t, c, tc.expectParam) |
| 1318 | }) |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | func TestRouterParam_escapeColon(t *testing.T) { |
| 1323 | // to allow Google cloud API like route paths with colon in them |
nothing calls this directly
no test coverage detected
searching dependent graphs…