Skip to content

Commit 41553b8

Browse files
Update AGENTS.md with guidance picked up while implement KV and PG commands (#484)
Document recommended practices to guide agents (and humans!) onto a default happy and successful path. GROW-2619 GitOrigin-RevId: d71f6274e8e2ea8d95b647f8f46888b27476edb5
1 parent 3496d2d commit 41553b8

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Prefer small, incremental changes over large speculative implementations.
4949
go build -o render . # Build binary
5050

5151
# Testing
52-
go test ./... # All tests
53-
go test -run TestName ./pkg/... # Single test
52+
go test ./cmd/... ./pkg/... ./internal/... # Default development loop
53+
go test <package> -run '<test-name-or-regex>' # Focused test pattern
5454

5555
# Linting & Formatting
5656
golangci-lint run # Lint
@@ -120,6 +120,17 @@ if command.IsInteractive(ctx) {
120120
return runNonInteractive(ctx, deps) // JSON, YAML, TEXT
121121
```
122122

123+
For commands without an interactive/TUI path, default interactive output to text
124+
at the top of `RunE`:
125+
126+
```go
127+
cmd.RunE = func(cmd *cobra.Command, args []string) error {
128+
command.DefaultFormatNonInteractive(cmd)
129+
130+
// parse input and run the non-interactive command path
131+
}
132+
```
133+
123134
**Naming**:
124135
| Element | Pattern | Example |
125136
|---------|---------|---------|
@@ -152,6 +163,38 @@ export RENDER_API_KEY="your-api-key"
152163
- **Table-driven tests** with `stretchr/testify`
153164
- **Manual fakes** in `pkg/tui/testhelper/`
154165
- **Hooks** (`prek.toml`): golangci-lint, shellcheck, shfmt, yaml checks, large file detection
166+
- **REST API fake** in `internal/fakes/renderapi` for command tests whose
167+
code paths hit the API; see `cmd/pglist_test.go` for the preferred harness
168+
pattern.
169+
170+
Run `go test ./cmd/... ./pkg/... ./internal/...` by default. `e2e/e2e_test.go`
171+
logs in and hits the configured Render API (`api.render.com` by default), so
172+
leave it out of the normal development loop. When using `-run`, target the
173+
package under test when you know it, e.g. `go test ./cmd -run TestPGList`;
174+
use the broader default package set when you want normal pre-review confidence.
175+
To run `e2e/e2e_test.go` locally, the human operator must first follow the
176+
[CLI E2E tests Slab doc](https://slab.render.com/posts/e-2-e-tests-ldk27n88).
177+
178+
Prefer the `renderapi` fake over one-off HTTP servers or API-layer mocks. Seed
179+
state with `renderapi.NewServer(t)`, resource factories, and server helpers; if
180+
coverage is missing, expand the shared fake unless a one-off server or mock is
181+
much more ergonomic for an edge case.
182+
183+
```go
184+
server := renderapi.NewServer(t)
185+
server.Owners.Add(renderapi.NewOwner(client.Owner{Id: activeWorkspaceID}))
186+
t.Setenv("RENDER_WORKSPACE", activeWorkspaceID)
187+
188+
project := server.CreateProject(
189+
renderapi.ProjectAttrs{Name: "My Project", OwnerId: activeWorkspaceID},
190+
renderapi.EnvAttrs{Name: "production"},
191+
)
192+
server.Postgres.Add(renderapi.NewPostgres(client.PostgresDetail{
193+
Name: "prod-db",
194+
Owner: client.Owner{Id: activeWorkspaceID},
195+
EnvironmentId: pointers.From(project.Env("production").Id),
196+
}))
197+
```
155198

156199
## Common Gotchas
157200

0 commit comments

Comments
 (0)