@@ -49,8 +49,8 @@ Prefer small, incremental changes over large speculative implementations.
4949go 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
5656golangci-lint run # Lint
@@ -120,6 +120,17 @@ if command.IsInteractive(ctx) {
120120return 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