Expand description
A throwaway Postgres for the lifetime of one command.
Replaces the sqlx-cli shell-out: the database is created and migrated
in-process through sqlx, using the same migrations/ directory the
server embeds via server::db::MIGRATOR. One set of migrations, one
migrator, no second implementation that can drift.
initdb and pg_ctl remain external programs because they are external
programs; there is no library form of them.
Structsยง
- Postgres
- A running cluster that stops itself when dropped.
Constantsยง
- DURABILITY_
OFF ๐ - Durability is off on purpose. This cluster is initdbโd moments earlier and dies with the container, so there is nothing for it to protect โ every fsync is pure cost, paid on cloud block storage, and 275 of the tests create and migrate a database of their own. Measured worth ~2m30s of a test run.
- PORT_
RANGE ๐ - Ports tried in order. No allocator to lean on, and
pg_ctl -wexits non-zero when the server fails to come up, so a busy port is self-correcting. - TIMEOUTS ๐
- Bounds on how long the server will let a client misbehave.
Staticsยง
- MIGRATOR ๐
- The projectโs migrations, embedded at compile time from the same directory
server::db::MIGRATORreads. Embedding needs no database, which is what lets this binary be built before the server it goes on to test.
Functionsยง
- create_
and_ ๐migrate - run ๐
- start
- initdb, start, create the database, migrate it.
- start_
on_ ๐free_ port