| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Syd.Def.Env
Synopsis
- eit :: HasCallStack => String -> ReaderT env IO () -> TestDef outers env
- withTestEnv :: env -> ReaderT env IO a -> IO a
Documentation
eit :: HasCallStack => String -> ReaderT env IO () -> TestDef outers env Source #
For defining a part of a test suite in 'ReaderT IO' instead of in IO.
This way you can write this:
spec :: Spec
spec = around withConnectionPool $
it "can read what it writes" $ \pool ->
let person = Person { name = "Dave", age = 25 }
i <- runSqlPool (insert person) pool
person' <- runSqlPool (get i) pool
person' `shouldBe` personlike this instead:
spec :: Spec
spec = around withConnectionPool $
eit "can read what it writes" $ do
let person = Person { name = "Dave", age = 25 }
i <- runDB $ insert person
person' <- runDB $ get i
liftIO $ person' `shouldBe` person
runDB :: ReaderT ConnectionPool IO a -> IO aNote that you use eit with a property test. In that case you would have to write it like this:
spec :: Spec
spec = around withConnectionPool $
it "can read what it writes" $ \pool -> do
forAllValid $ \person -> withTestEnv pool $ do
i <- runDB $ insert person
person' <- runDB $ get i
liftIO $ person' `shouldBe` person