Skip to content

Conversation

@appleboy
Copy link
Member

@appleboy appleboy commented Nov 7, 2024

if it needs to check if the handler is nil, tie c.index shall always ++.

add testing case for #4083 credit by @zjj

  • Test with no handlers: Verifies that calling Next() on a context with no handlers does not change the index property.
  • Test with one handler: Checks that a single handler is executed, the index is updated correctly, and the handler sets a key-value pair in the context.
  • Test with multiple handlers: Ensures that multiple handlers are executed in sequence, the index is updated correctly, and each handler can set key-value pairs in the context.
  • Key existence and value check: Confirms that the keys set by the handlers exist in the context and have the expected values.
  • Handler chaining: Validates that handlers can call Next() to pass control to the next handler in the chain and still perform actions before and after the call to Next().

cc @zjj

zjj and others added 3 commits October 27, 2024 15:40
if it needs to check if the handler is nil, tie c.index shall
always ++
- Remove an empty line in `TestContextInitQueryCache`
- Add `TestContextNext` function with tests for `Next` method behavior with no handlers, one handler, and multiple handlers

Signed-off-by: Bo-Yi Wu <[email protected]>
@appleboy appleboy added type/bug Found something you weren't expecting? Report it here! enhancement labels Nov 7, 2024
@appleboy appleboy added this to the v1.11 milestone Nov 7, 2024
@appleboy appleboy requested a review from thinkerou November 7, 2024 02:30
@codecov
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (3dc1cd6) to head (151f477).
Report is 80 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4087      +/-   ##
==========================================
- Coverage   99.21%   98.99%   -0.22%     
==========================================
  Files          42       44       +2     
  Lines        3182     3387     +205     
==========================================
+ Hits         3157     3353     +196     
- Misses         17       24       +7     
- Partials        8       10       +2     
Flag Coverage Δ
?
-tags "sonic avx" 98.98% <100.00%> (?)
-tags go_json 98.98% <100.00%> (?)
-tags nomsgpack 98.98% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 98.99% <100.00%> (-0.22%) ⬇️
go-1.22 98.99% <100.00%> (?)
macos-latest 98.99% <100.00%> (-0.22%) ⬇️
ubuntu-latest 98.99% <100.00%> (-0.22%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@appleboy
Copy link
Member Author

@thinkerou Please help to review.

@appleboy appleboy merged commit f875d87 into gin-gonic:master Nov 15, 2024
24 of 25 checks passed
@appleboy appleboy deleted the patch branch November 15, 2024 15:49
1911860538 pushed a commit to 1911860538/gin that referenced this pull request Feb 26, 2025
…nic#4087)

* enhance code imported by gin-gonic#3413

if it needs to check if the handler is nil, tie c.index shall
always ++

* test: refactor test context initialization and handler logic

- Remove an empty line in `TestContextInitQueryCache`
- Add `TestContextNext` function with tests for `Next` method behavior with no handlers, one handler, and multiple handlers

Signed-off-by: Bo-Yi Wu <[email protected]>

---------

Signed-off-by: Bo-Yi Wu <[email protected]>
Co-authored-by: zjj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement type/bug Found something you weren't expecting? Report it here!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants