Skip to content

test: migrate all Go tests to testify#345

Merged
wesm merged 1 commit into
mainfrom
feat/use-testify
May 26, 2026
Merged

test: migrate all Go tests to testify#345
wesm merged 1 commit into
mainfrom
feat/use-testify

Conversation

@wesm
Copy link
Copy Markdown
Member

@wesm wesm commented May 26, 2026

Summary

Standardizes Go tests on github.com/stretchr/testify. All 172 test files now use assert.X / require.X instead of t.Errorf / t.Fatalf.

What changed

  • t.Fatal* mapped to require.X (halts on failure).
  • t.Error* mapped to assert.X (continues on failure).
  • Equality argument order is (want, got) per testify convention.
  • Custom helpers in internal/testutil/assert.go (AssertEqual, MustNoErr, etc.) removed; MakeSet kept.
  • internal/testutil/email/email.go::AssertStringSliceEqual removed (unused after migration).
  • testify promoted to a direct dependency in go.mod.
  • CLAUDE.md gains a ## Testing section documenting the convention.
  • New AGENTS.md at the repo root reiterates the same rule for any AI coding agent.

Coverage

Production-code coverage is unchanged. Total moves 56.8% → 57.0% (improvement comes from testutil helpers whose error branches are no longer uncovered). 46/46 packages pass; same set as before.

How to use

New tests:

import (
    "github.com/stretchr/testify/assert"
    "github.com/stretchr/testify/require"
)

require.NoError(t, err, "context")
assert.Equal(t, want, got)

Build tags fts5 sqlite_vec are still required for go test; make test sets them.

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 26, 2026

roborev: Combined Review (ccec23e)

No Medium, High, or Critical issues found across the reviews.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 26, 2026

roborev: Combined Review (9ab93d7)

No Medium, High, or Critical findings were reported.

Both substantive review outputs indicate no issues found; the remaining review outputs are empty.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@mariusvniekerk
Copy link
Copy Markdown
Contributor

@wesm want too copy over the structure enforcement tool from middleman ?

@wesm
Copy link
Copy Markdown
Member Author

wesm commented May 26, 2026

yep, clanking

@wesm wesm force-pushed the feat/use-testify branch from 9ab93d7 to 8df410f Compare May 26, 2026 21:26
@wesm
Copy link
Copy Markdown
Member Author

wesm commented May 26, 2026

rebasing

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 26, 2026

roborev: Combined Review (8df410f)

Verdict: No medium-or-higher issues were found across the reviews.

All agents reported the code is clean or provided no findings.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

Standardizes Go test assertions on github.com/stretchr/testify. Across
all 172 test files, t.Fatal* maps to require.X (halts on failure) and
t.Error* maps to assert.X (continues on failure). Equality follows
testify's (want, got) convention.

internal/testutil/assert.go and internal/testutil/email's
AssertStringSliceEqual are removed in favor of calling testify directly.
MakeSet and other non-assertion helpers are kept.

Adds the testifyhelpercheck static analyzer (ported from middleman) to
enforce that assertion-heavy tests use local helpers (assert :=
assert.New(t), require := require.New(t)). All migrated tests are
refactored to satisfy this check: 798 scopes across 138 files have
helpers added, 5133 direct calls drop the t argument. Imports are
aliased to assertpkg/requirepkg to avoid package-vs-variable shadowing
in nested closures. The analyzer is wired into make lint-ci so CI
enforces the convention.

CLAUDE.md and AGENTS.md document testify as the standard. The nix
vendorHash is updated to match the new go.sum.
@wesm wesm force-pushed the feat/use-testify branch from 8df410f to 4f35c37 Compare May 26, 2026 21:33
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 26, 2026

roborev: Combined Review (4f35c37)

Summary verdict: No Medium, High, or Critical issues were reported.

All completed review agents found the code clean.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

Note: gemini review skipped (agent quota exhausted)

@wesm
Copy link
Copy Markdown
Member Author

wesm commented May 26, 2026

Merging. The CI failure is unrelated

@wesm wesm merged commit 874f841 into main May 26, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants