@@ -23,14 +23,15 @@ import Data.Monoid
2323import Data.Proxy
2424import qualified Data.Text as T
2525import GHC.Generics
26−import Network.HTTP.Client (HttpException(..))
26+import qualified Network.HTTP.Client as C
2727import Network.HTTP.Media
2828import Network.HTTP.Types
2929import Network.Socket
30−import Network.Wai
30+import Network.Wai hiding (Response)
3131import Network.Wai.Handler.Warp
3232import Test.Hspec
3333import Test.Hspec.QuickCheck
34+import Test.HUnit
3435import Test.QuickCheck
3536
3637import Servant.API
@@ -64,7 +65,7 @@ instance FromFormUrlEncoded Person where
6465
6566deriving instance Eq ServantError
6667
67−instance Eq HttpException where
68+instance Eq C.HttpException where
6869 a == b = show a == show b
6970
7071alice :: Person
@@ -128,8 +129,8 @@ getQueryFlag :: Bool -> BaseUrl -> EitherT ServantError IO Bool
128129getMatrixParam :: Maybe String -> BaseUrl -> EitherT ServantError IO Person
129130getMatrixParams :: [String] -> BaseUrl -> EitherT ServantError IO [Person]
130131getMatrixFlag :: Bool -> BaseUrl -> EitherT ServantError IO Bool
131−getRawSuccess :: Method -> BaseUrl -> EitherT ServantError IO (Int, ByteString, MediaType)
132−getRawFailure :: Method -> BaseUrl -> EitherT ServantError IO (Int, ByteString, MediaType)
132+getRawSuccess :: Method -> BaseUrl -> EitherT ServantError IO (Int, ByteString, MediaType, C.Response ByteString)
133+getRawFailure :: Method -> BaseUrl -> EitherT ServantError IO (Int, ByteString, MediaType, C.Response ByteString)
133134getMultiple :: String -> Maybe Int -> Bool -> [(String, [Rational])]
134135 -> BaseUrl
135136 -> EitherT ServantError IO (String, Maybe Int, Bool, [(String, [Rational])])
@@ -211,12 +212,22 @@ spec = do
211212 Arrow.left show <$> runEitherT (getMatrixFlag flag host) `shouldReturn` Right flag
212213
213214 it "Servant.API.Raw on success" $ withServer $ \ host -> do
214− (Arrow.left show <$> runEitherT (getRawSuccess methodGet host))
215− `shouldReturn` Right (200, "rawSuccess", "application"//"octet-stream")
215+ res <- runEitherT (getRawSuccess methodGet host)
216+ case res of
217+ Left e -> assertFailure $ show e
218+ Right (code, body, ct, response) -> do
219+ (code, body, ct) `shouldBe` (200, "rawSuccess", "application"//"octet-stream")
220+ C.responseBody response `shouldBe` body
221+ C.responseStatus response `shouldBe` ok200
216222
217223 it "Servant.API.Raw on failure" $ withServer $ \ host -> do
218− (Arrow.left show <$> runEitherT (getRawFailure methodGet host))
219− `shouldReturn` Right (400, "rawFailure", "application"//"octet-stream")
224+ res <- runEitherT (getRawFailure methodGet host)
225+ case res of
226+ Left e -> assertFailure $ show e
227+ Right (code, body, ct, response) -> do
228+ (code, body, ct) `shouldBe` (400, "rawFailure", "application"//"octet-stream")
229+ C.responseBody response `shouldBe` body
230+ C.responseStatus response `shouldBe` badRequest400
220231
221232 modifyMaxSuccess (const 20) $ do
222233 it "works for a combination of Capture, QueryParam, QueryFlag and ReqBody" $
@@ -262,7 +273,7 @@ spec = do
262273 Right host <- return $ parseBaseUrl "127.0.0.1:987654"
263274 Left res <- runEitherT (getGet host)
264275 case res of
265− ConnectionError (FailedConnectionException2 "127.0.0.1" 987654 False _) -> return ()
276+ ConnectionError (C.FailedConnectionException2 "127.0.0.1" 987654 False _) -> return ()
266277 _ -> fail $ "expected ConnectionError, but got " <> show res
267278
268279 it "reports UnsupportedContentType" $ withFailServer $ \ host -> do