Re:PostgreSQL example of self-contained stored procedures
by marcus_holmes on Monday October 28, 2019 @08:44AM
(#21376340)
agree on the mocking the database - I wrote an entire test suite based on mocking the database responses, and then found a ton of live problems caused by the database - backend interaction (things like structs not aligning with the actual return records from functions, input format for arrays of ids being different from the mockup to the actual driver, and hstores).
Now I have a test database, which I create from a version-controlled schema.sql, and each test creates its own fixtures in the test db. Works way better.
Mocking away DB is both an inefficient way to work and lets the tests cover less. I will never write software without running tests against a real DB again.
Our setup totally would let you test anything in stored procedures (although we do not use them much).