Repository navigation
test(node): add delete segments command unit tests - #4829
armnkumar321-spec wants to merge 4 commits into
Conversation
Cover DELETE_SEGMENTS.serialize: exact bytes for numeric and string stream/topic identifiers, and the 1..=1000 segment count bounds.
|
Thanks for the PR. It is labeled If AI assistance was used to create this PR, you are required to run the Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4829 +/- ##
============================================
- Coverage 91.29% 91.10% -0.20%
+ Complexity 4204 3878 -326
============================================
Files 1458 1563 +105
Lines 340825 406984 +66159
Branches 272619 340170 +67551
============================================
+ Hits 311170 370795 +59625
- Misses 23439 28784 +5345
- Partials 6216 7405 +1189
🚀 New features to boost your workflow:
|
|
Thanks @armnkumar321-spec, and welcome. You are right about the range. |
|
Thanks for the welcome! Opened #4850 for the segments-count range and the error message. |
Which issue does this PR address?
Closes #4795
Rationale
DELETE_SEGMENTS.serializein the Node SDK had no unit test, so a change to the payload layout or to the segments count bounds would go unnoticed.What changed?
Adds
foreign/node/src/wire/segment/delete-segments.command.test.ts(node:test+node:assert/strict, same layout ascreate-user.command.test.ts). No production code changed.topicId: 300encodes as2c 01 00 00, so the test also pins little-endian order.[2, length]followed by the name bytes.The expected buffers are built with
Buffer.concatfrom literal bytes and never callserializeIdentifieroruint32ToBuf. I made sure the tests fail if the partition id and segments count are swapped or the upper bound changes.One thing to confirm, outside this PR: the SDK rejects counts above 1000, but the server's
DeleteSegments::validateaccepts anyu32. These tests lock in the SDK's 1..=1000 range as it is today.Local Execution
In
foreign/nodeon macOS, Node 24.22.2:npm run test:unit: 971 tests passed, 0 failed.delete-segments.command.tsandsegment.utils.tsnow have 100% line, branch and function coverage.npm run lint: passed.npx tsc -p tsconfig.json --noEmit: passed.