| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Genesis.Test
- runDB :: MonadBaseControl IO m => SqlPersistT m a -> m a
 - runDBCommit :: MonadBaseControl IO m => SqlPersistT m a -> m a
 - withGlobalPostgresqlConn :: MonadBaseControl IO m => PostgresOptions -> m a -> m a
 - module Genesis.Test.Hspec
 - dbExample :: SqlPersistT IO () -> Expectation
 - module Genesis.Persist
 
Managing the global database connection
The bindings in this section are re-exported from Genesis.Test.Persist. For more information, see the module documentation for Genesis.Test.Persist.
runDB :: MonadBaseControl IO m => SqlPersistT m a -> m a Source #
Runs a computation that may interact with a database using the global database context, then rolls back the transaction once the computation has completed. This is intended to be wrapped around a single test case to create a self-contained test that interacts with the database.
If you are using hspec, the dbExample helper may be more useful and
  concise, but this function is provided for uses that fall outside of simple
  hspec examples.
runDBCommit :: MonadBaseControl IO m => SqlPersistT m a -> m a Source #
Like runDB, except that the transaction is commited after running instead of
  rolled back (unless an exception is raised, in which case the transaction is
  rolled back, anyway). You should avoid this in test code to avoid creating
  tests that dependent on the database state, but it can be useful to run
  migrations, for example.
withGlobalPostgresqlConn :: MonadBaseControl IO m => PostgresOptions -> m a -> m a Source #
Parameterizes the global database connection, dbConn, within the dynamic
  extent of its execution. The connection is started within a transaction.
HSpec helpers
module Genesis.Test.Hspec
dbExample :: SqlPersistT IO () -> Expectation Source #
A helper function that combines example with runDB. This can be used
  with it to create a test case which has access to the database within
  its body:
spec =describe"the database" $it"holds records" $dbExample$ do ...
When using this function, you should most likely also use Genesis.Test.Hspec instead of Test.Hspec to avoid unnecessarily lifting of assertions.
Other re-exports
module Genesis.Persist