From d10b56e8e527ab559ed4fbf9e569a0525c848cbc Mon Sep 17 00:00:00 2001 From: William Martin Date: Tue, 24 Mar 2026 19:55:51 +0100 Subject: [PATCH] Address review: table tests, godocs, code style Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 55a7c489f..98024f533 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -106,6 +106,30 @@ assert.Equal(t, "expected", actual) Interfaces use `moq`: `//go:generate moq -rm -out prompter_mock.go . Prompter`. Run `go generate ./...` after interface changes. +### Table-Driven Tests + +Use table-driven tests for functions with multiple input/output scenarios. See `internal/agents/detect_test.go` or `pkg/cmd/issue/list/list_test.go` for examples: + +```go +tests := []struct { + name string + // inputs and expected outputs +}{ + {name: "descriptive case name", ...}, +} +for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // arrange, act, assert + }) +} +``` + +## Code Style + +- Add godoc comments to all exported functions, types, and constants +- Avoid unnecessary code comments — only comment when the *why* isn't obvious from the code +- Do not comment just to restate what the code does + ## Error Handling Error types in `pkg/cmdutil/errors.go`: