Test Coverage Plans
Baseline: 51.0% total statements (2026-10-03, after PRs #41-#43).
Scope: pgsql, sqlexec, template, plus non-reader/writer packages. Other readers/writers deferred.
Order
Conventions
- Same package as code under test; table-driven; must pass
-race.
- Existing data first:
tests/assets/*, examples/*.dbml, tests/postgres/init.sql, tests/postgres/issue21. Generate new data only where listed under "Data needed".
- New fixtures go in
tests/assets/<format>/ or package testdata/.
- Live-DB tests: skip unless the env var is set (pattern in
pkg/readers/pgsql/reader_test.go). Use tests/dbtest/dbtest.sh (podman/docker; see tests/dbtest/README.md):
dbtest.sh up|down <postgres|mssql|mysql|all>
eval "$(dbtest.sh env postgres)" sets RELSPEC_TEST_PG_CONN (mssql: RELSPEC_TEST_MSSQL_CONN, mysql: RELSPEC_TEST_MYSQL_CONN)
dbtest.sh test <db> [pkgs] runs up, go test, down
- Fixtures for live DBs: postgres
tests/postgres/init.sql, mssql test_data/mssql/test_schema.sql, mysql tests/dbtest/init/mysql.sql.
- Prerequisite: working container networking (currently blocked until reboot into matching kernel;
tun module).
- Prefer pure-function tests over DB tests wherever the logic can be isolated.
- Output assertions must not depend on map order (see memory: map iteration determinism).
Targets
| Package |
Target |
| pgsql (all three) |
>= 85 |
| sqlexec |
>= 80 |
| template |
>= 85 |
| models |
>= 80 |
| cmd/relspec |
>= 65 |
| jobs |
>= 85 |
| ui |
>= 40 (data ops/pure helpers; screens via smoke tests) |
| diff, merge |
>= 85 |
| sqltypes |
>= 85 |
Verify
go test -race -coverprofile=c.out ./pkg/<pkg>/ then go tool cover -func=c.out
make test before commit