-
Notifications
You must be signed in to change notification settings - Fork 224
[ISSUE #5720][Test🧪] Add test case for LockBatchResponseBody #6040
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
[ISSUE #5720][Test🧪] Add test case for LockBatchResponseBody #6040
Conversation
|
🔊@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💥. |
WalkthroughThis pull request adds comprehensive test coverage for Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 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.
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
lockOKMQSetfield. - Add a
HashSetdeduplication test forMessageQueueentries.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mod test { | ||
| use super::*; | ||
| use serde_json; | ||
| use std::collections::HashSet; |
Copilot
AI
Feb 3, 2026
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.
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.
|
|
||
| let json = serde_json::to_string(&body).unwrap(); | ||
|
|
||
| assert!(json.contains("\"lockOKMQSet\"")); |
Copilot
AI
Feb 3, 2026
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.
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).
| 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" | |
| ); |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 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)
Brief Description
How Did You Test This Change?
Summary by CodeRabbit