sydtest 0.2.0.0 → 0.3.0.0
raw patch · 5 files changed
+12/−56 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Test.Syd: eit :: HasCallStack => String -> ReaderT env IO () -> TestDef outers env
- Test.Syd: withTestEnv :: env -> ReaderT env IO a -> IO a
- Test.Syd.Def.Env: eit :: HasCallStack => String -> ReaderT env IO () -> TestDef outers env
- Test.Syd.Def.Env: withTestEnv :: env -> ReaderT env IO a -> IO a
+ Test.Syd.Run: instance Test.Syd.Run.IsTest (Control.Monad.Trans.Reader.ReaderT env GHC.Types.IO ())
+ Test.Syd.Run: instance Test.Syd.Run.IsTest (outerArgs -> Control.Monad.Trans.Reader.ReaderT env GHC.Types.IO ())
Files
- src/Test/Syd.hs +0/−4
- src/Test/Syd/Def.hs +0/−2
- src/Test/Syd/Def/Env.hs +0/−48
- src/Test/Syd/Run.hs +11/−0
- sydtest.cabal +1/−2
src/Test/Syd.hs view
@@ -66,10 +66,6 @@ pending, pendingWith, - -- ** Environment-based tests- eit,- withTestEnv,- -- ** Golden tests pureGoldenTextFile, goldenTextFile,
src/Test/Syd/Def.hs view
@@ -1,7 +1,6 @@ -- | This module exports all the functions you will use to define your test suite. module Test.Syd.Def ( -- * Rexports- module Test.Syd.Def.Env, module Test.Syd.Def.Specify, module Test.Syd.Def.Around, module Test.Syd.Def.AroundAll,@@ -14,7 +13,6 @@ import Test.Syd.Def.Around import Test.Syd.Def.AroundAll-import Test.Syd.Def.Env import Test.Syd.Def.Golden import Test.Syd.Def.Scenario import Test.Syd.Def.SetupFunc
− src/Test/Syd/Def/Env.hs
@@ -1,48 +0,0 @@-module Test.Syd.Def.Env where--import Control.Monad.Reader-import GHC.Stack-import Test.Syd.Def.Specify-import Test.Syd.Def.TestDefM---- | 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` person------ like 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 a------ Note 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-eit :: HasCallStack => String -> ReaderT env IO () -> TestDef outers env-eit s f = it s (\env -> runReaderT f env)---- | Helper function to run a property test with an 'env'.------ > withTestEnv = flip runReaderT-withTestEnv :: env -> ReaderT env IO a -> IO a-withTestEnv = flip runReaderT
src/Test/Syd/Run.hs view
@@ -13,6 +13,7 @@ import Control.Concurrent import Control.Exception import Control.Monad.IO.Class+import Control.Monad.Reader import Data.IORef import Data.Map (Map) import qualified Data.Map as M@@ -109,6 +110,16 @@ type Arg1 (outerArgs -> innerArg -> IO ()) = outerArgs type Arg2 (outerArgs -> innerArg -> IO ()) = innerArg runTest = runIOTestWithArg++instance IsTest (ReaderT env IO ()) where+ type Arg1 (ReaderT env IO ()) = ()+ type Arg2 (ReaderT env IO ()) = env+ runTest func = runTest (\() -> func)++instance IsTest (outerArgs -> ReaderT env IO ()) where+ type Arg1 (outerArgs -> ReaderT env IO ()) = outerArgs+ type Arg2 (outerArgs -> ReaderT env IO ()) = env+ runTest func = runTest (\outerArgs env -> runReaderT (func outerArgs) env) runIOTestWithArg :: (outerArgs -> innerArg -> IO ()) ->
sydtest.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: sydtest-version: 0.2.0.0+version: 0.3.0.0 synopsis: A modern testing framework for Haskell with good defaults and advanced testing features. description: A modern testing framework for Haskell with good defaults and advanced testing features. Sydtest aims to make the common easy and the hard possible. See https://github.com/NorfairKing/sydtest#readme for more information. category: Testing@@ -28,7 +28,6 @@ Test.Syd.Def Test.Syd.Def.Around Test.Syd.Def.AroundAll- Test.Syd.Def.Env Test.Syd.Def.Golden Test.Syd.Def.Scenario Test.Syd.Def.SetupFunc