-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the gin.CreateTestContext in test, could not get the param in the route. #2778
Comments
Hello, Any thoughts on this? |
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Aug 3, 2021
@Hanaasagi We met the same issue and fixed it #2803, please feel free to leave suggestions. |
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Aug 3, 2021
@Hanaasagi i have same issue, is there any work around |
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Oct 3, 2021
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Jul 14, 2022
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Jul 14, 2022
RoCry
added a commit
to RoCry/gin
that referenced
this issue
Jul 14, 2022
Here's a workaround for now:
|
appleboy
pushed a commit
that referenced
this issue
Nov 6, 2022
fixed in #2803 and released in v1.8.2 |
thxCode
pushed a commit
to seal-io/gin
that referenced
this issue
Feb 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
#2755 only fixes the
slice bounds out of range
panic. Route params are not be handled correctly in test context. I can explain what happened.When call
CreateTestContext
, it will callNew
function to create aEngine
. ThemaxParams
will be the default value0
.gin/test_helpers.go
Lines 9 to 16 in 9c27053
Then
allocateContext
init theParams
. Thecap
andlen
are both 0.params
is the reference ofParams
.gin/gin.go
Lines 202 to 205 in 9c27053
Even if we add a route, it only incrs the
maxParams
value, it has not effect on theContext
we created byCreateTestContext
before. The condition will always befalse
.gin/tree.go
Lines 462 to 479 in 9c27053
How to reproduce
Expectations
Get following output after running the code.
Actual result
ctx.Param("name")
returns a empty string.Environment
The text was updated successfully, but these errors were encountered: