Fix remaining test cases
This commit is contained in:
parent
f5dd4bfdbd
commit
eba7d654c2
1 changed files with 9 additions and 7 deletions
|
@ -132,7 +132,6 @@ withServer action = withWaiDaemon (return server) action
|
||||||
|
|
||||||
type FailApi =
|
type FailApi =
|
||||||
"get" :> Raw
|
"get" :> Raw
|
||||||
:<|> "delete" :> Raw
|
|
||||||
:<|> "capture" :> Capture "name" String :> Raw
|
:<|> "capture" :> Capture "name" String :> Raw
|
||||||
:<|> "body" :> Raw
|
:<|> "body" :> Raw
|
||||||
failApi :: Proxy FailApi
|
failApi :: Proxy FailApi
|
||||||
|
@ -141,7 +140,6 @@ failApi = Proxy
|
||||||
failServer :: Application
|
failServer :: Application
|
||||||
failServer = serve failApi (
|
failServer = serve failApi (
|
||||||
(\ _request respond -> respond $ responseLBS ok200 [] "")
|
(\ _request respond -> respond $ responseLBS ok200 [] "")
|
||||||
:<|> (\ _request respond -> respond $ responseLBS ok200 [] "")
|
|
||||||
:<|> (\ _capture _request respond -> respond $ responseLBS ok200 [("content-type", "application/json")] "")
|
:<|> (\ _capture _request respond -> respond $ responseLBS ok200 [("content-type", "application/json")] "")
|
||||||
:<|> (\_request respond -> respond $ responseLBS ok200 [("content-type", "fooooo")] "")
|
:<|> (\_request respond -> respond $ responseLBS ok200 [("content-type", "fooooo")] "")
|
||||||
)
|
)
|
||||||
|
@ -275,6 +273,8 @@ spec = withServer $ \ baseUrl -> do
|
||||||
(WrappedApi (Proxy :: Proxy (Put '[JSON] ())), "Put") :
|
(WrappedApi (Proxy :: Proxy (Put '[JSON] ())), "Put") :
|
||||||
[]
|
[]
|
||||||
|
|
||||||
|
type RawRight = (Int, ByteString, MediaType, [HTTP.Header], C.Response ByteString)
|
||||||
|
|
||||||
failSpec :: IO ()
|
failSpec :: IO ()
|
||||||
failSpec = withFailServer $ \ baseUrl -> do
|
failSpec = withFailServer $ \ baseUrl -> do
|
||||||
let getGet :: EitherT ServantError IO Person
|
let getGet :: EitherT ServantError IO Person
|
||||||
|
@ -284,8 +284,11 @@ failSpec = withFailServer $ \ baseUrl -> do
|
||||||
( getGet
|
( getGet
|
||||||
:<|> getDelete
|
:<|> getDelete
|
||||||
:<|> getCapture
|
:<|> getCapture
|
||||||
:<|> getBody)
|
:<|> getBody
|
||||||
= client failApi baseUrl
|
:<|> _ )
|
||||||
|
= client api baseUrl
|
||||||
|
getGetWrongHost :: EitherT ServantError IO Person
|
||||||
|
(getGetWrongHost :<|> _) = client api (BaseUrl Http "127.0.0.1" 19872)
|
||||||
|
|
||||||
hspec $ do
|
hspec $ do
|
||||||
context "client returns errors appropriately" $ do
|
context "client returns errors appropriately" $ do
|
||||||
|
@ -302,10 +305,9 @@ failSpec = withFailServer $ \ baseUrl -> do
|
||||||
_ -> fail $ "expected DecodeFailure, but got " <> show res
|
_ -> fail $ "expected DecodeFailure, but got " <> show res
|
||||||
|
|
||||||
it "reports ConnectionError" $ do
|
it "reports ConnectionError" $ do
|
||||||
Right _ <- return $ parseBaseUrl "127.0.0.1:987654"
|
Left res <- runEitherT getGetWrongHost
|
||||||
Left res <- runEitherT getGet
|
|
||||||
case res of
|
case res of
|
||||||
ConnectionError (C.FailedConnectionException2 "127.0.0.1" 987654 False _) -> return ()
|
ConnectionError (C.FailedConnectionException2 "127.0.0.1" 19872 False _) -> return ()
|
||||||
_ -> fail $ "expected ConnectionError, but got " <> show res
|
_ -> fail $ "expected ConnectionError, but got " <> show res
|
||||||
|
|
||||||
it "reports UnsupportedContentType" $ do
|
it "reports UnsupportedContentType" $ do
|
||||||
|
|
Loading…
Add table
Reference in a new issue