Skip to content
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

Merged
merged 3 commits into from Sep 7, 2021

Conversation

filikos
Copy link
Contributor

@filikos filikos commented Aug 30, 2021

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.

@codecov
Copy link

codecov bot commented Aug 31, 2021

Codecov Report

Merging #2848 (783438c) into master (4e75841) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Flag Coverage Δ
go-1.13 98.75% <100.00%> (+<0.01%) ⬆️
go-1.14 98.59% <100.00%> (+<0.01%) ⬆️
go-1.15 98.59% <100.00%> (+<0.01%) ⬆️
go-1.16 98.59% <100.00%> (+<0.01%) ⬆️
macos-latest 98.75% <100.00%> (+<0.01%) ⬆️
nomsgpack 98.73% <100.00%> (+<0.01%) ⬆️
ubuntu-latest 98.75% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
context.go 97.98% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e75841...783438c. Read the comment docs.

context.go Outdated
// Example Route: "/user/:id"
// SetParam("id", 1)
// Result: "/user/1"
func (c *Context) SetParam(key, value string) {
Copy link
Member

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

Copy link
Contributor Author

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.

@appleboy appleboy added this to the v1.8 milestone Sep 2, 2021
@appleboy
Copy link
Member

appleboy commented Sep 7, 2021

LGTM, Waiting for @thinkerou review.

Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@thinkerou thinkerou merged commit deb83b6 into gin-gonic:master Sep 7, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants