Created
May 5, 2015 16:18
-
-
Save codedmart/2d5d7ee80b13c42a2202 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
| it "Returns headers appropriately" $ hspec $ withServer $ \ host -> do | |
| res <- runIO $ runEitherT getRespHeaders | |
| case res of | |
| Left e -> runIO $ assertFailure $ show e | |
| Right val -> runIO $ getHeaders val `shouldBe` [("X-Example1", "1729"), ("X-Example2", "eg2")] | |
| modifyMaxSuccess (const 20) $ do | |
| it "works for a combination of Capture, QueryParam, QueryFlag and ReqBody" $ | |
| property $ forAllShrink pathGen shrink $ \(NonEmpty cap) num flag body -> | |
| ioProperty $ do | |
| result <- Arrow.left show <$> runEitherT (getMultiple cap num flag body) | |
| return $ | |
| result === Right (cap, num, flag, body) | |
| context "client correctly handles error status codes" $ do | |
| let test :: (WrappedApi, String) -> Spec | |
| test (WrappedApi api, desc) = | |
| it desc $ hspec $ | |
| withWaiDaemon (return (serve api (left $ ServantErr 500 "error message" "" []))) $ | |
| \ host -> do | |
| let getResponse :: EitherT ServantError IO () | |
| getResponse = client api host | |
| Left FailureResponse{..} <- runIO $ 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") : | |
| [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment