Skip to content

add hermetic tests for EscapeTag, statsd, LoadConfig, HTTPS, UrlString#52

Merged
dolph merged 1 commit into
mainfrom
claude/fix-issue-47-pure-function-tests
May 16, 2026
Merged

add hermetic tests for EscapeTag, statsd, LoadConfig, HTTPS, UrlString#52
dolph merged 1 commit into
mainfrom
claude/fix-issue-47-pure-function-tests

Conversation

@dolph
Copy link
Copy Markdown
Owner

@dolph dolph commented May 16, 2026

Summary

Adds table-driven, hermetic tests for the bug-prone pure functions identified in #47. Test-only change; no production code is modified.

Each bug-documenting case is commented // Refs #N -- flip when fixed so a future fix has a green target to flip rather than a silent passing test.

Test plan

  • go vet ./... clean
  • gofmt -l . prints nothing
  • go build ./... succeeds
  • go test -race ./... — all 19 new tests pass; only the pre-existing TestRouteToLoopback{1,2,3} failures from sandbox routing (Tests aren't hermetic and major modules are untested; production code is hard to test #24) remain, which also fail on origin/main
  • Tests are hermetic: no real network beyond loopback httptest, no filesystem outside t.TempDir(), no routing-table reads
  • Subprocess-based TestLoadConfig_MissingFileFatals uses an env-gated helper branch to safely cover the log.Fatalf path without killing the parent test process

Fixes #47

https://claude.ai/code/session_01WjHPSobuzrRkjwUgjAJWMk


Generated by Claude Code

Adds table-driven tests for pure functions that previously had no coverage,
all hermetic per AGENTS.md (no real network beyond loopback httptest, no
filesystem outside t.TempDir).

- statsd_test.go: EscapeTag for :, |, ,, @ plus a refs-#14 case pinning the
  missing newline/CR handling. Count/Timer/Gauge wire-format assertions
  with queue draining to keep package state clean between cases.
- config_test.go: LoadConfig with t.TempDir fixtures (empty path, minimal
  YAML, multi-URL), a refs-#6 case encoding the map[string]string loader
  bug, and a subprocess-based check pinning the log.Fatalf-on-missing-file
  boundary.
- https_test.go: HTTPS against httptest.NewServer covering 2xx success,
  refs-#7 (5xx still reports success), refs-#15 (silently follows
  redirects), and a dial-failure case that's already correct.
- destinations_test.go: TestUrlString table-driven cases pinning password
  redaction as "[...]" (refs #12), userinfo variants, custom paths, the
  icmp port=-1 omission, and the scheme!=protocol parens annotation.

Tests for known bugs (#6, #7, #12, #14, #15) document current behavior so
future fixes have a failing target to flip; each is marked
"Refs #N -- flip when fixed".

Fixes #47

https://claude.ai/code/session_01WjHPSobuzrRkjwUgjAJWMk
@dolph dolph added the release:skip label May 16, 2026 — with Claude
@dolph dolph merged commit 732c2bc into main May 16, 2026
2 checks passed
@dolph dolph deleted the claude/fix-issue-47-pure-function-tests branch May 16, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug-prone pure functions have zero test coverage: EscapeTag, statsd wire format, UrlString redaction, LoadConfig, HTTPS

2 participants