git.iko.soy/typeable/servant
on master help sign in
Fix remaining test cases
commiteba7d654c2a9b548968f892c5b6f029ec5df0583 authorJulian K. Arni <jkarni@gmail.com> dateFri 8 May 2015, 15:07 (11 years ago) parentf5dd4bf
1 file changed+9−7
servant-client/test/Servant/ClientSpec.hs+9−7
servant-client/test/Servant/ClientSpec.hs+9−7
@@ -132,7 +132,6 @@ withServer action = withWaiDaemon (return server) action
132132
133133type FailApi =
134134 "get" :> Raw
135− :<|> "delete" :> Raw
136135 :<|> "capture" :> Capture "name" String :> Raw
137136 :<|> "body" :> Raw
138137failApi :: Proxy FailApi
@@ -141,7 +140,6 @@ failApi = Proxy
141140failServer :: Application
142141failServer = serve failApi (
143142 (\ _request respond -> respond $ responseLBS ok200 [] "")
144− :<|> (\ _request respond -> respond $ responseLBS ok200 [] "")
145143 :<|> (\ _capture _request respond -> respond $ responseLBS ok200 [("content-type", "application/json")] "")
146144 :<|> (\_request respond -> respond $ responseLBS ok200 [("content-type", "fooooo")] "")
147145 )
@@ -275,6 +273,8 @@ spec = withServer $ \ baseUrl -> do
275273 (WrappedApi (Proxy :: Proxy (Put '[JSON] ())), "Put") :
276274 []
277275
276+type RawRight = (Int, ByteString, MediaType, [HTTP.Header], C.Response ByteString)
277+
278278failSpec :: IO ()
279279failSpec = withFailServer $ \ baseUrl -> do
280280 let getGet :: EitherT ServantError IO Person
@@ -284,8 +284,11 @@ failSpec = withFailServer $ \ baseUrl -> do
284284 ( getGet
285285 :<|> getDelete
286286 :<|> getCapture
287− :<|> getBody)
288− = client failApi baseUrl
287+ :<|> getBody
288+ :<|> _ )
289+ = client api baseUrl
290+ getGetWrongHost :: EitherT ServantError IO Person
291+ (getGetWrongHost :<|> _) = client api (BaseUrl Http "127.0.0.1" 19872)
289292
290293 hspec $ do
291294 context "client returns errors appropriately" $ do
@@ -302,10 +305,9 @@ failSpec = withFailServer $ \ baseUrl -> do
302305 _ -> fail $ "expected DecodeFailure, but got " <> show res
303306
304307 it "reports ConnectionError" $ do
305− Right _ <- return $ parseBaseUrl "127.0.0.1:987654"
306− Left res <- runEitherT getGet
308+ Left res <- runEitherT getGetWrongHost
307309 case res of
308− ConnectionError (C.FailedConnectionException2 "127.0.0.1" 987654 False _) -> return ()
310+ ConnectionError (C.FailedConnectionException2 "127.0.0.1" 19872 False _) -> return ()
309311 _ -> fail $ "expected ConnectionError, but got " <> show res
310312
311313 it "reports UnsupportedContentType" $ do