go-test-writerlisted
Install: claude install-skill prilive-com/go-tdd-pack
# Go Test Writer
Write or extend tests for Go code in this repo.
## Conventions (non-negotiable)
- **Table-driven by default.** Unless the scenario is genuinely
non-tabular, write a `tests := []struct{...}` slice with subtests.
- **Use `t.Run(tt.name, ...)` for subtests.** Enables
`-run TestX/subname` filtering.
- **`require` for setup errors, `assert` for assertions.** Stop
execution on setup failure (no point continuing); accumulate
assertion failures. From `github.com/stretchr/testify/require` and
`.../assert`.
- **`t.Helper()` in test helpers.** Points failures at the caller, not
the helper.
- **`t.Cleanup(func(){...})` over `defer`.** Runs in reverse order of
registration and survives `t.Parallel`.
- **`t.Parallel()` for leaf tests.** Not for tests that share mutable
state.
- **`t.Setenv(...)`** when testing env-var-reading code.
- **`testdata/` for fixture files.** Go test runner ignores this
directory name.
## Test types and when to use each
### Unit test
Pure functions, small struct methods, no I/O. Table-driven default.
### Integration test
Anything touching a DB, filesystem, network, or concurrency. Uses real
dependencies where feasible: `testcontainers-go` Postgres for pgx
code, `httptest.NewServer` for HTTP clients. Build tag
`//go:build integration` if the repo separates slow tests.
### Race test
Required when goroutines are involved. Run via `go test -race`. Test
body should exercise concurrent paths (spawn goroutines that hit the
sha