-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An persistent-postgresql companion library for sydtest -- -- An persistent-postgresql companion library for sydtest @package sydtest-persistent-postgresql @version 0.2.0.1 -- | Testing with a temporary postgresql database using -- persistent-postgresql module Test.Syd.Persistent.Postgresql -- | Declare a test suite that uses a database connection. -- -- Example usage -- --
-- -- Database definition
-- share
-- [mkPersist sqlSettings, mkMigrate "migrateExample"]
-- [persistLowerCase|
-- Person
-- name String
-- age Int Maybe
-- deriving Show Eq
-- |]
--
-- -- Tests
-- spec :: Spec
-- spec =
-- persistPostgresqlSpec migrateExample $ do
-- it "can write and read this example person" $ \pool ->
-- runPostgresqlTest pool $ do
-- let p = Person {personName = "John Doe", personAge = Just 21}
-- i <- insert p
-- mp <- get i
-- liftIO $ mp `shouldBe` Just p
--
--
-- This sets up the database connection around every test, so state is
-- not preserved accross tests.
persistPostgresqlSpec :: Migration -> SpecWith ConnectionPool -> SpecWith a
-- | Set up a postgresql connection and migrate it to run the given
-- function.
withConnectionPool :: Migration -> (ConnectionPool -> IO r) -> IO r
-- | The SetupFunc version of withConnectionPool.
connectionPoolSetupFunc :: Migration -> SetupFunc ConnectionPool
-- | Get a connection from the pool, run the given action, and then return
-- the connection to the pool.
--
-- This function performs the given action in a transaction. If an
-- exception occurs during the action, then the transaction is rolled
-- back.
--
-- Note: This function previously timed out after 2 seconds, but this
-- behavior was buggy and caused more problems than it solved. Since
-- version 2.1.2, it performs no timeout checks.
runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a
-- | A flipped version of runSqlPool to run your tests
runPostgresqlTest :: ConnectionPool -> SqlPersistM a -> IO a