[Test🧪] Add test case for GetLiteTopicInfoRequestHeader#6614
Conversation
Add unit tests covering: - Header creation with field values - Serialization to map (to_map) - Deserialization from map (from_map) - Clone behavior - Debug formatting Closes mxsm#6572
|
🔊@slegarraga 🚀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 new test module was added to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
rocketmq-remoting/src/protocol/header/get_lite_topic_info_request_header.rs (1)
67-82: Add a failure-path test for missing required map keys.The deserialization happy path is covered, but a missing-key case would harden regression protection for
#[required]fields.➕ Suggested test addition
#[test] fn get_lite_topic_info_request_header_deserializes_from_map() { @@ } + +#[test] +fn get_lite_topic_info_request_header_deserialize_fails_when_required_field_missing() { + let mut map = HashMap::new(); + map.insert( + CheetahString::from_static_str("parentTopic"), + CheetahString::from("deserialized_parent"), + ); + + let result = <GetLiteTopicInfoRequestHeader as FromMap>::from(&map); + assert!(result.is_err()); +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rocketmq-remoting/src/protocol/header/get_lite_topic_info_request_header.rs` around lines 67 - 82, Add a failing-path unit test for GetLiteTopicInfoRequestHeader deserialization: write a test (e.g., get_lite_topic_info_request_header_deserializes_from_map_missing_keys) that builds a HashMap missing one or both required keys ("parentTopic" or "liteTopic"), then call <GetLiteTopicInfoRequestHeader as FromMap>::from(&map) and assert it returns an Err (or panics if that is the convention) to validate the #[required] behavior; use the same CheetahString keys as the existing test and assert the error variant/message expected by the FromMap implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rocketmq-remoting/src/protocol/header/get_lite_topic_info_request_header.rs`:
- Around line 67-82: Add a failing-path unit test for
GetLiteTopicInfoRequestHeader deserialization: write a test (e.g.,
get_lite_topic_info_request_header_deserializes_from_map_missing_keys) that
builds a HashMap missing one or both required keys ("parentTopic" or
"liteTopic"), then call <GetLiteTopicInfoRequestHeader as FromMap>::from(&map)
and assert it returns an Err (or panics if that is the convention) to validate
the #[required] behavior; use the same CheetahString keys as the existing test
and assert the error variant/message expected by the FromMap implementation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6614 +/- ##
==========================================
- Coverage 41.52% 41.36% -0.16%
==========================================
Files 961 964 +3
Lines 134645 135272 +627
==========================================
+ Hits 55909 55957 +48
- Misses 78736 79315 +579 ☔ 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.
LGTM - All CI checks passed ✅
Motivation
Closes #6572
Modification
Added unit tests for
GetLiteTopicInfoRequestHeadercovering:to_map)from_map)Result
All 5 tests pass. Improves test coverage for the remoting protocol headers.
Summary by CodeRabbit