This repository is a skeleton that integrates pgtap and graphile-worker.
In this skeleton, two PostgreSQL databases are defined in docker-compose.yml
:
postgres
, is the "working" database, used by developer to develop its applicationpostgres-test
, is the database used to run unit tests, via pgTAP (version 1.2.0
)Why two separate databases? For two reasons:
Important details:
contacts
table is declared in the main
schemapublic
schema is removed and never usedsearch_path
configuration option is set to ""
, then you must always specify the schema for each table$ asdf install
$ pnpm install
$ ./scripts/init.sh
Next, execute:
$ pnpm run migrate:watch
Execute tests:
$ pnpm run migrate-test:watch
$ ./scripts/tests.sh
/sqls/tests/test1.sql .. ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.01 cusr 0.00 csys = 0.02 CPU)
Result: PASS
You can also run a specific test:
$ ./scripts/tests.sh sqls/tests/test1.sql
/sqls/tests/test1.sql .. ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.01 cusr 0.00 csys = 0.02 CPU)
Result: PASS
Apply migration in migrations/current.sql
and commit:
$ pnpm run migrate:commit