(t *testing.T)
| 2517 | } |
| 2518 | |
| 2519 | func TestPathValuesSizeOverMultipleRequests(t *testing.T) { |
| 2520 | e := New() |
| 2521 | e.GET("/test/:id/:action", handlerFunc) // max params is 2 |
| 2522 | |
| 2523 | req := httptest.NewRequest(http.MethodGet, "/test/1/a", nil) |
| 2524 | rec := httptest.NewRecorder() |
| 2525 | |
| 2526 | c := e.AcquireContext() |
| 2527 | c.Reset(req, rec) |
| 2528 | assert.Equal(t, 0, len(*c.pathValues)) // fresh context is empty |
| 2529 | assert.Equal(t, 2, cap(*c.pathValues)) // is set max path params amount |
| 2530 | |
| 2531 | // imitate some (pre)middleware changing/replacing pathparams to smaller size |
| 2532 | c.SetPathValues(PathValues{ |
| 2533 | {Name: "id", Value: "1"}, |
| 2534 | }) |
| 2535 | assert.Equal(t, 1, len(*c.pathValues)) // as SetPathValues was provided |
| 2536 | assert.Equal(t, 2, cap(*c.pathValues)) // SetPathValues did not change that to smaller |
| 2537 | |
| 2538 | handler := e.router.Route(c) |
| 2539 | e.ReleaseContext(c) |
| 2540 | |
| 2541 | assert.NoError(t, handler(c)) |
| 2542 | assert.Equal(t, 2, len(*c.pathValues)) // matched route had 2 path params |
| 2543 | assert.Equal(t, 2, cap(*c.pathValues)) // was not changed |
| 2544 | assert.Equal(t, "1", c.Param("id")) |
| 2545 | assert.Equal(t, "a", c.Param("action")) |
| 2546 | } |
| 2547 | |
| 2548 | // Issue #1655 |
| 2549 | func TestRouterFindNotPanicOrLoopsWhenContextSetParamValuesIsCalledWithLessValuesThanEchoMaxParam(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…