Keep sah-cli easy to change without regressing worker behavior, CLI guidance, or compatibility with already deployed SCIENCE@home servers.
internal/sah/*_test.go: unit tests for worker protocol handling, auth helpers, service-manager integration, payload parsing, summaries, and compatibility shims.cmd/sah/*_test.go: command-facing tests for discovery output, help text, onboarding suggestions, and user-visible follow-up guidance.- HTTP client tests use
httptest.Serverto lock request paths, headers, and JSON decoding against the current API contract.
- When adding a new protocol path, keep existing fallbacks working until the deployed API no longer needs them.
- When code accepts both current and legacy response shapes, leave a short code comment at the fallback branch and add a test that proves both shapes still work.
- Keep examples and command descriptions aligned with the current onboarding and daemon behavior. Update docs in the same change when CLI output meaning changes.
Run these before pushing:
go test ./...
./scripts/check_coverage.sh 35
golangci-lint run ./...
GOOS=linux GOARCH=amd64 golangci-lint run ./...Coverage is enforced through ./scripts/check_coverage.sh and must stay at or above 35%.
golangci-lint also enforces:
gocognitfor cognitive complexityfunlenfor function lengthduplfor duplicated blocks
The shared .githooks/pre-commit hook runs the same coverage and lint gates plus:
go mod verifygo mod tidywith a no-diff checkCGO_ENABLED=1 go test -race ./...go build -o .tmp-bin/sah ./cmd/sah
Enable it once per clone:
git config core.hooksPath .githooks- Add or update tests for every user-visible command behavior change.
- Add or update compatibility tests when touching legacy fields, fallback routes, or worker contract negotiation.
- Keep docs small and topic-specific. If build instructions grow test-specific detail, move that detail here and link back from
build.mdorAGENTS.md.