Created
May 5, 2015 11:54
-
-
Save codedmart/7b3c02960b2d890c9e29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "client correctly handles error status codes" $ do | |
| let test :: (WrappedApi, String) -> Spec | |
| test (WrappedApi api, desc) = | |
| it desc $ | |
| withWaiDaemon (return (serve api (left (500, "error message")))) $ | |
| \ host -> do | |
| let getResponse :: EitherT ServantError IO () | |
| getResponse = client api host | |
| Left FailureResponse{..} <- liftIO $ runEitherT getResponse | |
| runIO $ responseStatus `shouldBe` (Status 500 "error message") | |
| mapM_ test $ | |
| (WrappedApi (Proxy :: Proxy Delete), "Delete") : | |
| (WrappedApi (Proxy :: Proxy (Get '[JSON] ())), "Get") : | |
| (WrappedApi (Proxy :: Proxy (Post '[JSON] ())), "Post") : | |
| (WrappedApi (Proxy :: Proxy (Put '[JSON] ())), "Put") : | |
| [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test/Servant/ClientSpec.hs:4:11: | |
| Could not deduce (Arg Spec ~ ()) | |
| from the context (HasServer (Canonicalize api), | |
| Server api ~ EitherT (Int, String) IO a, | |
| HasClient (Canonicalize api), | |
| Client api ~ EitherT ServantError IO ()) | |
| bound by a pattern with constructor | |
| WrappedApi :: forall api a. | |
| (HasServer (Canonicalize api), | |
| Server api ~ EitherT (Int, String) IO a, | |
| HasClient (Canonicalize api), | |
| Client api ~ EitherT ServantError IO ()) => | |
| Proxy api -> WrappedApi, | |
| in an equation for ‘test’ | |
| at test/Servant/ClientSpec.hs:246:15-28 | |
| Expected type: Spec | |
| Actual type: SpecWith (Arg Spec) | |
| In the expression: | |
| it desc | |
| $ withWaiDaemon (return (serve api (left (500, "error message")))) | |
| $ \ host | |
| -> do { let ...; | |
| Left (FailureResponse {..}) <- liftIO $ runEitherT getResponse; | |
| .... } | |
| In an equation for ‘test’: | |
| test (WrappedApi api, desc) | |
| = it desc | |
| $ withWaiDaemon (return (serve api (left (500, "error message")))) | |
| $ \ host | |
| -> do { let ...; | |
| .... } | |
| In the second argument of ‘($)’, namely | |
| ‘do { let test :: (WrappedApi, String) -> Spec | |
| test (WrappedApi api, desc) | |
| = it desc $ withWaiDaemon (return (serve api (left ...))) $ ...; | |
| mapM_ test | |
| $ (WrappedApi (Proxy :: Proxy Delete), "Delete") | |
| : (WrappedApi (Proxy :: Proxy (Get '[JSON] ())), "Get") | |
| : (WrappedApi (Proxy :: Proxy (Post '[JSON] ())), "Post") | |
| : (WrappedApi (Proxy :: Proxy (Put '[JSON] ())), "Put") : [] }’ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment