test(encoding): add direct unit tests for sink encodings - #37
Open
Donemmanuelo wants to merge 1 commit into
Open
test(encoding): add direct unit tests for sink encodings#37Donemmanuelo wants to merge 1 commit into
Donemmanuelo wants to merge 1 commit into
Conversation
Covers the framing and shaping logic that previously had no direct coverage: RFC 3164 and RFC 5424 frame structure, Loki stream grouping by label set with nanosecond timestamps, account_id defaulting, timestamp parsing/fallback robustness, header parsing edge cases, encoding name round-trips, and the cross-transport validation errors. The targeted functions are exposed as pub(crate) so the existing single test module can exercise them directly.
onelrian
reviewed
Aug 13, 2026
| fn test_timestamp_to_nanoseconds_handles_unparseable_input() { | ||
| // Robustness contract: a malformed timestamp must not panic or fail the | ||
| // whole batch encode; it resolves to a numeric fallback. The exact | ||
| // fallback value is pinned by a test in #35. |
Owner
There was a problem hiding this comment.
onelrian
reviewed
Aug 13, 2026
| } | ||
|
|
||
| fn timestamp_to_nanoseconds(timestamp: &str) -> String { | ||
| pub(crate) fn timestamp_to_nanoseconds(timestamp: &str) -> String { |
Owner
There was a problem hiding this comment.
Stacking note: #37, #38 and #39 all touch timestamp_to_nanoseconds / tests.rs / process_cycle (same author, all open). They'll conflict on merge - merge in a defined order (#37 -> #38 -> #39) or stack them as one branch. Also, no CI checks are reported on this fork branch; make sure the test gate actually runs before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33.
User-facing impact
No behavior change. The encoding layer — RFC 3164/5424 framing, the Loki
push-request builder, timestamp-to-nanosecond conversion, and header
parsing — previously had no direct tests, only happy-path coverage through
mock sink tests. These 13 unit tests pin the wire formats, label-set
grouping,
account_iddefaulting, fallback robustness, and thecross-transport validation errors, so regressions now fail fast.
Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings, andcargo test --lockedall pass (41 tests).pub(crate)so the existing singletest module can exercise them; no public API changes.