Skip to content

Conversation

@oopscompiled
Copy link
Contributor

@oopscompiled oopscompiled commented Feb 3, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for batch response handling, including serialization/deserialization and deduplication behavior.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@oopscompiled 🚀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 Feb 3, 2026

Walkthrough

This pull request adds comprehensive test coverage for LockBatchResponseBody, including tests for default state initialization, JSON field name serialization, successful deserialization from JSON data, and HashSet behavior with MessageQueue equality and deduplication.

Changes

Cohort / File(s) Summary
Test Module for LockBatchResponseBody
rocketmq-remoting/src/protocol/body/response/lock_batch_response_body.rs
Adds test module with four test cases covering default state, JSON serialization field names, deserialization from JSON, and HashSet deduplication semantics for MessageQueue instances.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A test for locking batches fair,
HashSets dancing without a care,
Messages queue, then dedupe with grace—
The lockOKMQSet finds its place! ✨

🚥 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 PR title clearly indicates adding a test case for LockBatchResponseBody, which matches the primary change in the changeset.
Linked Issues check ✅ Passed The PR adds comprehensive test cases for LockBatchResponseBody including default state, JSON serialization, deserialization, and HashSet behavior, fulfilling the requirement in issue #5720.
Out of Scope Changes check ✅ Passed All changes are scoped to adding test cases for LockBatchResponseBody with no modifications to public API or unrelated code.
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 docstrings
🧪 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds unit test coverage for LockBatchResponseBody to validate default initialization, serde field renaming (lockOKMQSet), JSON deserialization, and HashSet<MessageQueue> behavior.

Changes:

  • Add default-state test for LockBatchResponseBody.
  • Add serde JSON serialization/deserialization tests covering the lockOKMQSet field.
  • Add a HashSet deduplication test for MessageQueue entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +31
mod test {
use super::*;
use serde_json;
use std::collections::HashSet;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

In this crate/directory the convention is to name the test module tests (plural). This file introduces mod test, which is inconsistent with nearby response body modules (e.g. rocketmq-remoting/src/protocol/body/response/get_consumer_status_body.rs:54). Consider renaming the module to tests for consistency.

Copilot uses AI. Check for mistakes.

let json = serde_json::to_string(&body).unwrap();

assert!(json.contains("\"lockOKMQSet\""));
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

test_serialization_json_field_name asserts the serialized JSON contains a substring, which is a fairly brittle check (it could pass even if the JSON structure changes as long as the substring appears somewhere). A more robust assertion would be to parse into serde_json::Value and assert the top-level object contains the lockOKMQSet key (and optionally that it is an array of length 1).

Suggested change
assert!(json.contains("\"lockOKMQSet\""));
let value: serde_json::Value = serde_json::from_str(&json).unwrap();
let obj = value.as_object().expect("Top-level JSON is not an object");
let lock_set = obj
.get("lockOKMQSet")
.expect("Missing 'lockOKMQSet' field in JSON");
assert!(
lock_set.is_array(),
"'lockOKMQSet' field is not serialized as an array"
);
assert_eq!(
lock_set.as_array().unwrap().len(),
1,
"'lockOKMQSet' array should contain exactly one element"
);

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.54%. Comparing base (56810e4) to head (520b0c9).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6040   +/-   ##
=======================================
  Coverage   40.54%   40.54%           
=======================================
  Files         881      882    +1     
  Lines      122549   122587   +38     
=======================================
+ Hits        49682    49706   +24     
- Misses      72867    72881   +14     

☔ 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 ✅

@mxsm mxsm merged commit 0cdf4d6 into mxsm:main Feb 4, 2026
17 of 27 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 Feb 4, 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 LockBatchResponseBody

4 participants