News for hackers. Stuff that matters.
Re:Database mocks are just not worth it by TobiasBales on Monday December 30, 2024 @04:05PM (#42553507)
I think one helpful thing is what rails calls transactional tests (https://guides.rubyonrails.org/testing.html#transactions). It basically does the database setup (migrations and seeds) and then executes the tests in a transaction that is rolled back at the end (and thus never committed). This helps with speed and also ensuring that tests don't have as much accidental codependence as they might otherwise.

If you use read replicas in production code this can become tricky though since the transactions don't commit they never become visible to the reader or even different connections to the same database

There are no comments on this comment yet.