Skip to content

test: add direct unit tests for sink encodings #33

Description

@Donemmanuelo

Problem to solve

The trickiest logic in the codebase — format_rfc3164, format_rfc5424,
build_loki_push_request, timestamp_to_nanoseconds in src/sinks/encoding.rs
and parse_headers in src/config.rs — has no direct unit tests. It is only
exercised indirectly through happy-path sink tests (a 200/204 mock), so framing
errors, label-set regressions, and fallback paths would ship unnoticed.

Proposed outcome

Direct unit tests covering:

  • RFC 3164 and RFC 5424 frame structure: PRI, timestamp passthrough, tag/APP-NAME,
    JSON MSG part, framing newline
  • Loki push request shape: per-label-set stream grouping, account_id default
    to unknown, nanosecond timestamps, log-line JSON
  • timestamp_to_nanoseconds: RFC3339 with Z, with offset, and the unparseable
    fallback path
  • parse_headers: happy path, whitespace trimming, missing-colon errors, empty
    entries
  • Cross-transport validation errors (syslog encoding on http transport and
    vice versa)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions