-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
gin.Context.SetParam shortcut for e2e tests #2848
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2848 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 41 41
Lines 3054 3056 +2
=======================================
+ Hits 3016 3018 +2
Misses 26 26
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
context.go
Outdated
// Example Route: "/user/:id" | ||
// SetParam("id", 1) | ||
// Result: "/user/1" | ||
func (c *Context) SetParam(key, value string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change name to AddParam
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, I changed the name to AddParam
. I also ran gofmt -s -w context.go && gofmt -s -w context_test.go
to fix https://github.com/gin-gonic/gin/runs/3468382048?check_suite_focus=true
Please let me know if there is more feedback.
LGTM, Waiting for @thinkerou review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* Added SetParam shortcut for e2e tests, added SetParam test * Adjusted naming and formatting * fixed typo
While writing e2e tests I noticed that adding path params can be simplified further.
Instead of appending params to the gin context like this:
c.Params = append(c.Params, Param{Key: key,Value: value})
The function
SetParam
will do the same but increase usability for writing e2e tests.