on master help sign in
Remove HUnit dependency
commit3273d6062a5a27d2fd5a7b5ec25d9c89847eac58 authorMichael Snoyman <michael@snoyman.com> dateThu 20 Mar 2014, 10:39 (13 years ago) parent9a66a22
2 files changed+17−5
wai-test/Network/Wai/Test.hs+15−3 wai-test/wai-test.cabal+2−2
wai-test/Network/Wai/Test.hs+15−3
@@ -1,5 +1,6 @@
11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE CPP #-}
3+{-# LANGUAGE DeriveDataTypeable #-}
34module Network.Wai.Test
45 ( -- * Session
56 Session
@@ -19,13 +20,17 @@ module Network.Wai.Test
1920 , assertBodyContains
2021 , assertHeader
2122 , assertNoHeader
23+ , WaiTestFailure (..)
2224 ) where
2325
2426import Network.Wai
25−import qualified Test.HUnit.Base as H
2627import Control.Monad.IO.Class (liftIO)
2728import Control.Monad.Trans.State (StateT, evalStateT)
2829import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask)
30+import Control.Monad (unless)
31+import Control.DeepSeq (deepseq)
32+import Control.Exception (throwIO, Exception)
33+import Data.Typeable (Typeable)
2934import Data.Map (Map)
3035import qualified Data.Map as Map
3136import Data.ByteString (ByteString)
@@ -108,10 +113,17 @@ runResponse res = do
108113 toBuilder C.Flush = flush
109114
110115assertBool :: String -> Bool -> Session ()
111−assertBool s b = liftIO $ H.assertBool s b
116+assertBool s b = unless b $ assertFailure s
112117
113118assertString :: String -> Session ()
114−assertString s = liftIO $ H.assertString s
119+assertString s = unless (null s) $ assertFailure s
120+
121+assertFailure :: String -> Session ()
122+assertFailure msg = msg `deepseq` liftIO (throwIO (WaiTestFailure msg))
123+
124+data WaiTestFailure = WaiTestFailure String
125+ deriving (Show, Eq, Typeable)
126+instance Exception WaiTestFailure
115127
116128assertContentType :: ByteString -> SResponse -> Session ()
117129assertContentType ct SResponse{simpleHeaders = h} =
wai-test/wai-test.cabal+2−2
@@ -1,5 +1,5 @@
11name: wai-test
2−version: 2.0.0.2
2+version: 2.0.1
33license: MIT
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
@@ -23,10 +23,10 @@ library
2323 , conduit >= 0.5 && < 1.1
2424 , blaze-builder-conduit >= 0.5 && < 1.1
2525 , cookie >= 0.2 && < 0.5
26− , HUnit >= 1.2 && < 1.3
2726 , http-types >= 0.7
2827 , case-insensitive >= 0.2
2928 , network
29+ , deepseq
3030 exposed-modules: Network.Wai.Test
3131 ghc-options: -Wall
3232