goalline / Database inputs
Test caching that notices when the database schema changed
A test run can pass because of the database it hit, not the code. goalline run --input db=pg reads the schema PostgreSQL reports right before and right after the gate and keeps its hash on the receipt, so a pass on one schema never stands in for another.
The problem
Test result caching keys on the code. But a dev database that drifted, a migration that half-applied or another server version can make the same code pass or fail, and the cache can't see any of it.
Name what the gate depends on
goalline run --gate api --reuse --input db=pg -- npx jest apps/api
goalline verify --require unit,api --input db=pg
goalline reads each input right before and right after the gate and keeps a hash of it on the receipt. In verify and --reuse, the receipt counts only while the same probe reads the same thing, and never when an input changed during the run. --reuse says why an earlier pass no longer counts.
PostgreSQL: db=pg
db=pgreads the schema PostgreSQL reports for$DATABASE_URL:pg_dump --schema-only --no-owner --no-privileges, without the lines that change on every dump (pg_dump's own version, the random\restrictkey), plus the server's major version.db=pg:TEST_DATABASE_URLreads another variable.- Prisma's own URL parameters (
?schema=public) are dropped before pg_dump sees the URL. - A password in a probe's URL never reaches the receipt.
Any other database
Any other probe is a command whose output says what matters:
goalline run --gate api --input db="sqlite3 dev.db .schema" -- npm test
goalline run --gate api --input db="mysqldump --no-data --skip-dump-date app" -- npm test
Only the gates that use it
In rules.json, inputs says which gates depend on what, so a schema change doesn't re-run the unit tests:
{ "inputs": { "api-*": ["db"] } }
A gate the rules tie to an input that no --input reads gets a receipt that proves nothing, and says why.
Limits
- Per gate, not per test: any schema change re-runs the whole gate.
- The clock is watched on its own: see the clock.
Related
- How it works: old tests on new code, the verdicts, and what it can't catch
- Claude Code hook: a Stop hook that won't let the agent finish until it explains a moved test
- GitHub Action: one step in a workflow, with Jest, Vitest or pytest
- prove-red: new tests must fail on the base code first, or they test nothing
- Skip what passed: signed receipts keyed by the git tree, and safe reuse
- The clock: which tests read the real clock, and passes that expire
- Benchmark: 31 flags on 400 merged PRs, each with its PR's reason
- Commands: every command and option