✅ Improve tests for v18 - #16
Conversation
There was a problem hiding this comment.
Pull request overview
This PR renames the family of Parse(..., out, ...) entry points to ParseInto(..., dest, ...) across the parser pipeline (session, command, reliable, fragment, connect, acknowledge, parameter decoders), reorders the hooks/dest argument convention, and renames Header → SessionHeader/CommandHeader and Type → MessageType to disambiguate them. It also reorganizes the reader package by splitting scalar and varint read helpers into dedicated files and substantially improves the v18 parameter test suite by replacing log-only smoke tests with real assertions and removing dead panic-on-error / benchmark scaffolding.
Changes:
- Rename
Parse/parseHeader/parseMetadatatoParseInto/readSessionHeaderInto/readCommandHeaderInto/readReliableHeaderInto/readFragmentHeader, swap the parameterHooks/destordering, renametypes.Header→SessionHeader/CommandHeaderandtypes.Type→MessageType, and delete the unusedcommand/pingandcommand/disconnectpackages. - Split
internal/reader/reader.gointoscalars.goandvarint.go, and add doc comments toSkip/ReadRemainingand thecontext.Contexttype. - Replace the v18 parameter "log-and-pass" tests with real assertions on command type and payload content; rename a few tests for clarity (e.g.
TestMalFormedHeader→TestWrongHeader,TestDecode→TestDecodeReliableCommand).
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| parser.go | Updates call site to session.ParseInto. |
| parser_test.go | Removes an unused OnCommandSync hook from a v18 test. |
| internal/types/session.go | Renames embedded Header to SessionHeader. |
| internal/types/command.go | Renames Header → CommandHeader, Type → MessageType, types UnknownPayload field, prunes per-constant doc comments. |
| internal/types/hooks.go | Updates OnEvents map key type to MessageType. |
| internal/hooks/hooks.go | Updates NewHooks to construct OnEvents with MessageType. |
| internal/context/context.go | Adds package-level doc comment for Context. |
| internal/context/decoders.go | Updates ParameterParser interface to ParseInto(reader, hooks, dest). |
| internal/session/session.go | Renames Parse → ParseInto, drops local Session wrapper, renames helpers. |
| internal/session/session_test.go | Updates to ParseInto and renames TestMalFormedHeader → TestWrongHeader. |
| internal/command/command.go | Renames Parse → ParseInto, splits header/payload helpers, reorders functions. |
| internal/command/command_test.go | Updates call to command.ParseInto. |
| internal/command/reliable/reliable.go | Renames Parse → ParseInto, parseHeader → readReliableHeaderInto, uses MessageType. |
| internal/command/reliable/reliable_test.go | Updates to ParseInto. |
| internal/command/reliable/fragment.go | Renames to ParseIntoFragment/readFragmentHeader, adds doc comment. |
| internal/command/connect/connect.go | Renames Parse → ParseInto. |
| internal/command/acknowledge/acknowledge.go | Renames Parse → ParseInto. |
| internal/command/disconnect/disconnect.go | Deletes unused stub package. |
| internal/command/ping/ping.go | Deletes unused stub package. |
| internal/reader/reader.go | Removes scalar/varint helpers (now in separate files), adds doc comments. |
| internal/reader/scalars.go | New file containing all scalar/string/byte read methods. |
| internal/reader/varint.go | New file containing varint read methods. |
| internal/parameters/v16/parameters.go | Renames Parse → ParseInto, swaps hooks/dest order. |
| internal/parameters/v16/scan_*_test.go | Updates calls to ParseInto. |
| internal/parameters/v18/parameters.go | Renames Parse → ParseInto, swaps argument order. |
| internal/parameters/v18/parameters_test.go | Replaces log-only tests with real assertions, renames tests, removes dead benchmark/encrypted tests. |
| internal/parameters/v18/scan_*_test.go | Updates calls to ParseInto. |
| .mise/config.toml | Adds coverage-html task and writes coverage profile to ressources/coverage.out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.