| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Syd.Persistent
Contents
Description
Testing with an in-memory sqlite database using persistent-sqlite
Synopsis
- runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a
- runPersistentTest :: ConnectionPool -> SqlPersistM a -> IO a
- migrationRunner :: MonadIO m => Migration -> ReaderT SqlBackend m ()
- migrationsSucceedsSpecHelper :: (Migration -> SetupFunc ConnectionPool) -> FilePath -> Migration -> Spec
Documentation
runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a #
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.
runPersistentTest :: ConnectionPool -> SqlPersistM a -> IO a Source #
A flipped version of runSqlPool to run your tests
migrationRunner :: MonadIO m => Migration -> ReaderT SqlBackend m () Source #
Helper function to run a Migration before/in a test suite that works accross versions of persistent.
migrationsSucceedsSpecHelper Source #
Arguments
| :: (Migration -> SetupFunc ConnectionPool) | Setupfunc for a ConnectionPool. This will be passed an empty migration |
| -> FilePath | |
| -> Migration | |
| -> Spec |
Test that the given migration succeeds, when applied to the current database.
This uses two tests:
- A golden test for the current migration.
- A test that first applies the golden migration, and then the current migration, tee see if that fails.
Orphan instances
| IsTest (SqlPersistM ()) Source # | |
Methods runTest :: SqlPersistM () -> TestRunSettings -> ProgressReporter -> ((Arg1 (SqlPersistM ()) -> Arg2 (SqlPersistM ()) -> IO ()) -> IO ()) -> IO TestRunResult # | |
| IsTest (outerArgs -> SqlPersistM ()) Source # | |
Methods runTest :: (outerArgs -> SqlPersistM ()) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> SqlPersistM ()) -> Arg2 (outerArgs -> SqlPersistM ()) -> IO ()) -> IO ()) -> IO TestRunResult # | |