Loading...
Loading...
How Go tests are written in these repos: assertions, tables, test doubles, helpers, async waits, golden files, fuzzing, benchmarks, and integration tests against a real Postgres via the bundled pgtest helper (one shared testcontainer, a fresh database per test). TRIGGER — load BEFORE writing, editing or reviewing any *_test.go file, testdata/ golden file, fuzz target or benchmark, or when the task says go test, test helper, fake, mock, stub, table test, testcontainers, TestMain, test database, flaky test or coverage in a Go repo. Plain requests count: "write the tests", "add a test for this", "fix the failing test", or a feature task whose last step is testing it. Load alongside go-idiomatic and tdd, not instead of them. SKIP when no Go test code is written or judged.
npx skill4agent add o-marsters-1997/my-claude-code go-testingtesting-policytdd| You reach for | Do this instead |
|---|---|
testify | Plain |
| |
A table with | Two tests: a success table and an error table checked with |
gomock, mockery, | A stateful in-memory fake; assert on the state it ends in |
| A real Postgres from |
| |
| A fresh database per test, so |
| A channel the code signals, a deadline poll, or |
| |
| A new test dependency | Only |
package foo_testpackage fooexport_test.gointernal/pgtestinternal/pgtestreferences/integration-db.mdcmp.Diff(want, got)(-want +got)go.modgithub.com/google/go-cmpgo get==slices.Equalmaps.Equalreflect.DeepEqualFunc(in) = got, want wanterrors.Iserrors.Asnamet.Run(tt.name, ...)t.Errort.Fatalt.Fataltt.Helper()t.CleanupassertEqualtime.Sleepsynctest.Testt.Parallel()t.Setenvt.Chdirpgtest-updatetestdata/fuzz/maingo test ./...-shortTEST_DATABASE_URLpgtestt.Skipgo test -race ./...golangci-lint run| If you're writing… | Load |
|---|---|
A test that touches Postgres, or a repo with no | |
CI for database tests ( | |
| A unit, table, fake plus contract suite, HTTP, async, golden, fuzz or benchmark test | |
assets/pgtest/assets/golangci-depguard.ymlinternal/pgtest| Skill | When |
|---|---|
| Everything about the code under test |
| Writing the test first, one behaviour at a time |
| What to test: test kinds, their value, reusable patterns (per repo) |