Repository navigation
gin.Context.SetParam shortcut for e2e tests - #2848
Merged
Merged
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.
|
appleboy
reviewed
Sep 1, 2021
| // Example Route: "/user/:id" | ||
| // SetParam("id", 1) | ||
| // Result: "/user/1" | ||
| func (c *Context) SetParam(key, value string) { |
Contributor
Author
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.
daheige
approved these changes
Sep 6, 2021
appleboy
approved these changes
Sep 7, 2021
Member
|
LGTM, Waiting for @thinkerou review. |
daheige
pushed a commit
to daheige/gin
that referenced
this pull request
Apr 18, 2022
* Added SetParam shortcut for e2e tests, added SetParam test * Adjusted naming and formatting * fixed typo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.