Skip to content

Fix test helpers to print the field under test, not the container#50

Merged
dolph merged 1 commit into
mainfrom
claude/fix-issue-46-test-helpers
May 16, 2026
Merged

Fix test helpers to print the field under test, not the container#50
dolph merged 1 commit into
mainfrom
claude/fix-issue-46-test-helpers

Conversation

@dolph
Copy link
Copy Markdown
Owner

@dolph dolph commented May 16, 2026

Summary

  • assertPortEquals, assertSchemeEquals, assertHostEquals now take the field under test directly so failure messages print the actual mismatched value instead of routing through *Destination.String(). The %s for an int bug in assertPortEquals is gone with it.
  • assertNoError/assertError accept a name string for call-site context (better than the previous unused *Destination argument), and a new assertErrorContains(t, err, substr) helper is available for tests that should pin which error came back — addressing the "checklist theater" pattern AGENTS.md calls out.
  • Every helper calls t.Helper() so failure lines point at the caller, not the helper.
  • Meta-tests using a capturing fake testing.T lock in the new failure-message contract (e.g. assertPortEquals must mention "Port" and both numeric values).
  • TestTcpUrlWithoutPort and TestUdpUrlWithoutPort now assert on the "Unsupported scheme" substring instead of just "some error came back," so an unrelated regression in NewDestination can no longer make them silently pass.
  • resolver_test.go call sites are updated to pass a context-name string. router_test.go and source_test.go define their own helpers and didn't need changes.

Test plan

  • go vet ./... — clean
  • gofmt -l . — empty
  • go build ./... — clean
  • go test -race ./... — same pass/fail set as origin/main; the pre-existing TestRouteToLoopback{1,2,3} failures are the documented sandbox-routing issue from Tests aren't hermetic and major modules are untested; production code is hard to test #24 (not a regression)
  • All new TestAssert* meta-tests pass and would fail to compile against the old helper signatures (the TDD "right reason")

Fixes #46

https://claude.ai/code/session_01WjHPSobuzrRkjwUgjAJWMk


Generated by Claude Code

The shared assertion helpers in destinations_test.go printed the whole
*Destination via %s instead of the int/string field they claimed to be
checking, so when an assertion fired the failure message hid the value
that mismatched. assertError accepted any error, which is the checklist
theater AGENTS.md warns against.

This change rewrites each helper to take the field directly (matching
AGENTS.md's "test helpers take only the field under test" guidance),
adds t.Helper() so failure lines point at the caller, and adds
assertErrorContains for tests that should pin which error came back.
Meta-tests using a capturing fake testing.T lock in the new failure
message format. Call sites in resolver_test.go are updated to pass a
context name instead of *Destination.

Fixes #46

https://claude.ai/code/session_01WjHPSobuzrRkjwUgjAJWMk
@dolph dolph added the release:skip label May 16, 2026 — with Claude
dolph added a commit that referenced this pull request May 16, 2026
The release workflow defaults to a patch bump when a merged PR has
no release:* label. Docs-only PR #45 and test-only PR #50 were both
opened unlabeled because AGENTS.md only mentioned the labels exist
without instructing agents to apply one. #45 likely cut an empty
patch release; #50 needed retroactive labeling before merge.

Replace the passing mention with a short rubric covering when to
use skip / patch / minor / major, and an explicit "before merge"
deadline so future agents pick exactly one.

https://claude.ai/code/session_01WjHPSobuzrRkjwUgjAJWMk

Co-authored-by: Claude <noreply@anthropic.com>
@dolph dolph merged commit 21ba377 into main May 16, 2026
2 checks passed
@dolph dolph deleted the claude/fix-issue-46-test-helpers branch May 16, 2026 14:57
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.

Test helpers in destinations_test.go use wrong format verbs and print the container instead of the field

2 participants