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

chore(context): test context initialization and handler logic #4087

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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 this to the v1.11 milestone Nov 7, 2024
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 79 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.

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.

3 participants