- **Refactor `internal/env` for testability.** Route every `os`/filesystem call in `env.go` through swappable package-level function variables (`getEnv`, `setEnv`, `lookupEnv`, `openFile`). Split `parseEnvFile` into a thin file-opening wrapper plus a pure `parseEnvReader(io.Reader)` so the parser can be tested directly without touching disk. - **Hermetic tests, 96.9% coverage.** Rewrite `internal/env/env_test.go` to install in-memory fakes via `withFakeEnv` / `withFakeOpen` helpers that swap the package vars and restore them on `t.Cleanup`. Tests no longer mutate real process env or write temp `.env` files, removing a source of flakiness under parallel test execution. New cases cover `NewEnvironment`, `setEnvDefault`, `loadEnvFile` error paths, and edge cases in the parser. - **Counterfeiter-based fake generation.** Add `counterfeiter` as a Go tool dependency, a `//go:generate` directive for the `Environment` interface (`internal/env/gen.go`), and commit the generated `internal/env/envfakes/fake_environment.go` so downstream packages can test against a spec-faithful fake instead of hand-rolling stubs. Expose the step as `make generate`. - **Tooling.** `scripts/proxy-utest.sh` gains a `--coverage` / `-c` flag that runs `go test -coverprofile=...` across `./cmd/...` and `./internal/...` and prints per-function coverage via `go tool cover -func`. The `srs-develop` skill doc is updated to include the regenerate-fakes step and the new coverage flag. - **Go version.** Bump `go.mod` to Go 1.25 (required for the `go tool` directive used to pin the counterfeiter CLI as a tool dep). --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
28 lines
428 B
Makefile
28 lines
428 B
Makefile
.PHONY: all build test fmt clean run generate
|
|
|
|
all: build
|
|
|
|
build: fmt bin/srs-proxy
|
|
|
|
generate:
|
|
go generate ./...
|
|
|
|
bin/srs-proxy: cmd/proxy/*.go internal/**/*.go
|
|
@mkdir -p bin
|
|
go build -o bin/srs-proxy ./cmd/proxy
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
fmt: ./.go-formarted
|
|
|
|
./.go-formarted: cmd/proxy/*.go internal/**/*.go
|
|
touch .go-formarted
|
|
go fmt ./cmd/... ./internal/...
|
|
|
|
clean:
|
|
rm -rf bin .go-formarted
|
|
|
|
run: fmt
|
|
go run ./cmd/proxy
|