Hacker News new | ask | show | jobs
by joevandyk 4428 days ago
What I do for my rails apps are:

* at the start of a test run, create a new database, load the schema into it, load all the 'global' data that all the tests need into the database.

* write that data to a sql file using pg_dump --inserts -a

* before each test runs, I disable triggers (with set session_replication_role=replica), then delete all the data from each table, then load the data from the sql file back into the database.

This allows me to have data quickly cleaned out and restored on every test run and gives me real transactions during tests.