Skip to content

Commit 3baabeb

Browse files
committed
Docs: Update Go test guidelines
Signed-off-by: Michael Mayer <[email protected]>
1 parent 0a66f14 commit 3baabeb

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Note: Across our public documentation, official images, and in production, the c
121121
- Full unit test suite: `make test` (runs backend and frontend tests)
122122
- Test frontend/backend: `make test-js` and `make test-go`
123123
- Go packages: `go test` (all tests) or `go test -run <name>` (specific tests only)
124+
- Go tests live beside sources: for `path/to/pkg/<file>.go`, add tests in `path/to/pkg/<file>_test.go` (create if missing). For the same function, group related cases as `t.Run(...)` sub-tests (table-driven where helpful).
124125
- Frontend unit tests are driven by Vitest; see scripts in `frontend/package.json`
125126
- Vitest watch/coverage: `make vitest-watch` and `make vitest-coverage`
126127
- Acceptance tests: use the `acceptance-*` targets in the `Makefile`
@@ -213,6 +214,7 @@ If anything in this file conflicts with the `Makefile` or the Developer Guide, t
213214

214215
### Testing
215216

217+
- Go tests: When adding tests for sources in `path/to/pkg/<file>.go`, always place them in `path/to/pkg/<file>_test.go` (create this file if it does not yet exist). For the same function, group related cases as sub-tests with `t.Run(...)` (table-driven where helpful).
216218
- Prefer targeted runs for speed:
217219
- Unit/subpackage: `go test ./internal/<pkg> -run <Name> -count=1`
218220
- Commands: `go test ./internal/commands -run <Name> -count=1`

CODEMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ Conventions & Rules of Thumb
173173
- Never log secrets; compare tokens constant‑time.
174174
- Don’t import Portal internals from cluster instance/service bootstraps; use HTTP.
175175
- Prefer small, hermetic unit tests; isolate filesystem paths with `t.TempDir()` and env like `PHOTOPRISM_STORAGE_PATH`.
176+
- Go tests live beside sources: for `path/to/pkg/<file>.go`, add tests in `path/to/pkg/<file>_test.go` (create if missing). For the same function, group related cases as `t.Run(...)` sub-tests (table-driven where helpful).
176177

177178
Frequently Touched Files (by topic)
178179
- CLI wiring: `cmd/photoprism/photoprism.go`, `internal/commands/commands.go`

0 commit comments

Comments
 (0)