-
Notifications
You must be signed in to change notification settings - Fork 218
[ISSUE #5376]🧪Add test case for RpcClientError #5446
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
Conversation
|
🔊@WaterWhisperer 🚀Thanks for your contribution🎉! 💡CodeRabbit(AI) will review your code first🔥! Note 🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥. |
WalkthroughA test module for Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
rocketmq-error/src/unified/rpc.rs (2)
90-116: Consider verifying the error source chain forRequestFailed.The tests successfully verify string representations and constructor helpers for all error variants. However, the
RequestFailedvariant has a#[source]attribute (line 32) that enables error chaining, but this behavior is not tested.💡 Add test for error source chain
Consider adding a test that verifies the source error is accessible:
#[test] fn test_request_failed_preserves_source() { let source = io::Error::other("network error"); let err = RpcClientError::request_failed("127.0.0.1:10911", 10, 3000, source); // Verify the source chain is preserved assert!(err.source().is_some()); assert_eq!(err.source().unwrap().to_string(), "network error"); }
90-116: Consider splitting into separate test functions.All error variants are tested in a single function, which makes it harder to identify which specific variant fails if a test breaks.
💡 Split into focused test functions
Consider splitting into separate test functions for better clarity:
#[test] fn test_broker_not_found() { let err = RpcClientError::broker_not_found("broker-a"); assert_eq!( err.to_string(), "Broker 'broker-a' address not found in client metadata" ); } #[test] fn test_request_failed() { let source = io::Error::other("network error"); let err = RpcClientError::request_failed("127.0.0.1:10911", 10, 3000, source); assert_eq!( err.to_string(), "RPC request failed: addr=127.0.0.1:10911, request_code=10, timeout=3000ms" ); } // ... similar pattern for other variants
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-error/src/unified/rpc.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Code Coverage
- GitHub Check: Build & Test (macos-latest)
- GitHub Check: Build & Test (ubuntu-latest)
- GitHub Check: Build & Test (windows-latest)
- GitHub Check: auto-approve
🔇 Additional comments (1)
rocketmq-error/src/unified/rpc.rs (1)
84-89: LGTM! Test module setup is correct.The test module structure and imports are appropriate for testing the RpcClientError variants.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5446 +/- ##
==========================================
+ Coverage 37.83% 37.86% +0.03%
==========================================
Files 811 811
Lines 109905 109921 +16
==========================================
+ Hits 41582 41625 +43
+ Misses 68323 68296 -27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rocketmq-rust-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - All CI checks passed ✅
Which Issue(s) This PR Fixes(Closes)
Fixes #5376
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.