Skip to content

[Test🧪] Add test case for GetLiteTopicInfoRequestHeader#6614

Merged
mxsm merged 1 commit intomxsm:mainfrom
slegarraga:test-6572
Mar 1, 2026
Merged

[Test🧪] Add test case for GetLiteTopicInfoRequestHeader#6614
mxsm merged 1 commit intomxsm:mainfrom
slegarraga:test-6572

Conversation

@slegarraga
Copy link
Contributor

@slegarraga slegarraga commented Mar 1, 2026

Motivation

Closes #6572

Modification

Added unit tests for GetLiteTopicInfoRequestHeader covering:

  • Header creation with field values
  • Serialization to map (to_map)
  • Deserialization from map (from_map)
  • Clone behavior
  • Debug formatting

Result

All 5 tests pass. Improves test coverage for the remoting protocol headers.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for request header components, including validation of serialization and deserialization functionality.

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
@rocketmq-rust-bot
Copy link
Collaborator

🔊@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💥.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

A new test module was added to GetLiteTopicInfoRequestHeader containing unit tests that verify creation, map serialization/deserialization via FromMap trait, cloning, and debug formatting capabilities.

Changes

Cohort / File(s) Summary
Unit Tests
rocketmq-remoting/src/protocol/header/get_lite_topic_info_request_header.rs
Added #[cfg(test)] module with comprehensive unit tests covering object creation, serialization to map, deserialization from map via FromMap trait, cloning behavior, and debug output formatting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hop! Tests for headers, crisp and clear,
GetLiteTopicInfoRequestHeader shines here!
Maps and clones and debug too,
Coverage grows—a tester's breakthrough! 🧪✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding test cases for GetLiteTopicInfoRequestHeader, which matches the changeset content.
Linked Issues check ✅ Passed The pull request successfully adds unit tests for GetLiteTopicInfoRequestHeader, directly addressing the requirements specified in linked issue #6572.
Out of Scope Changes check ✅ Passed All changes are scoped to adding unit tests for GetLiteTopicInfoRequestHeader with no unrelated modifications present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c59f59 and 1c10a65.

📒 Files selected for processing (1)
  • rocketmq-remoting/src/protocol/header/get_lite_topic_info_request_header.rs

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.36%. Comparing base (c803c98) to head (1c10a65).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a 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 ✅

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

LGTM

@mxsm mxsm merged commit 5f978f3 into mxsm:main Mar 1, 2026
11 of 22 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Mar 1, 2026
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.

[Test🧪] Add test case for GetLiteTopicInfoRequestHeader

4 participants