bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
370 stars 107 forks source link

Pass ConnectionPool to tests #262

Closed parsonsmatt closed 3 years ago

parsonsmatt commented 3 years ago

This PR inverts control in the test suite. Instead of having each test suite provide a run function which runs the database action, the test suite expects a ConnectionPool to be made available to it. Then the various backends use beforeAll :: IO ConnectionPool -> SpecWith ConnectionPool -> Spec to make it happen.

A further advantage is that we'll be able to use beforeWith :: (ConnectionPool -> IO ConnectionPool) -> SpecWith ConnectionPool -> SpecWith ConnectionPool to implement things like, y'know, inserting test/setup data into the database, and afterWith to clean it up.

Before submitting your PR, check that you've:

After submitting your PR: