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.
|
| // Example Route: "/user/:id" | ||
| // SetParam("id", 1) | ||
| // Result: "/user/1" | ||
| func (c *Context) SetParam(key, value string) { |
There was a problem hiding this comment.
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. |
* 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
SetParamwill do the same but increase usability for writing e2e tests.