diff --git a/test/Servant/ClientSpec.hs b/test/Servant/ClientSpec.hs index 51abeacc..812d10c4 100644 --- a/test/Servant/ClientSpec.hs +++ b/test/Servant/ClientSpec.hs @@ -157,9 +157,9 @@ spec = do (Arrow.left show <$> runEitherT (getBody p host)) `shouldReturn` Right p it "Servant.API.QueryParam" $ withServer $ \ host -> do - (Arrow.left show <$> runEitherT (getQueryParam (Just "alice") host)) `shouldReturn` Right alice - Left (FailureResponse s _ _) <- runEitherT (getQueryParam (Just "bob") host) - statusCode s `shouldBe` 400 + Arrow.left show <$> runEitherT (getQueryParam (Just "alice") host) `shouldReturn` Right alice + Left FailureResponse{..} <- runEitherT (getQueryParam (Just "bob") host) + responseStatus `shouldBe` Status 400 "bob not found" it "Servant.API.QueryParam.QueryParams" $ withServer $ \ host -> do (Arrow.left show <$> runEitherT (getQueryParams [] host)) `shouldReturn` Right [] @@ -171,22 +171,20 @@ spec = do it (show flag) $ withServer $ \ host -> do (Arrow.left show <$> runEitherT (getQueryFlag flag host)) `shouldReturn` Right flag -{- it "Servant.API.MatrixParam" $ withServer $ \ host -> do - runEitherT (getMatrixParam (Just "alice") host) `shouldReturn` Right alice - Left result <- runEitherT (getMatrixParam (Just "bob") host) - result `shouldContain` "bob not found" + Arrow.left show <$> runEitherT (getMatrixParam (Just "alice") host) `shouldReturn` Right alice + Left FailureResponse{..} <- runEitherT (getMatrixParam (Just "bob") host) + responseStatus `shouldBe` Status 400 "bob not found" it "Servant.API.MatrixParam.MatrixParams" $ withServer $ \ host -> do - runEitherT (getMatrixParams [] host) `shouldReturn` Right [] - runEitherT (getMatrixParams ["alice", "bob"] host) + Arrow.left show <$> runEitherT (getMatrixParams [] host) `shouldReturn` Right [] + Arrow.left show <$> runEitherT (getMatrixParams ["alice", "bob"] host) `shouldReturn` Right [Person "alice" 0, Person "bob" 1] context "Servant.API.MatrixParam.MatrixFlag" $ forM_ [False, True] $ \ flag -> it (show flag) $ withServer $ \ host -> do - runEitherT (getMatrixFlag flag host) `shouldReturn` Right flag --} + Arrow.left show <$> runEitherT (getMatrixFlag flag host) `shouldReturn` Right flag it "Servant.API.Raw on success" $ withServer $ \ host -> do (Arrow.left show <$> runEitherT (getRawSuccess methodGet host)) @@ -214,8 +212,8 @@ spec = do \ host -> do let getResponse :: BaseUrl -> EitherT ServantError IO () getResponse = client api - Left (FailureResponse status _ _) <- runEitherT (getResponse host) - status `shouldBe` (Status 500 "error message") + Left FailureResponse{..} <- runEitherT (getResponse host) + responseStatus `shouldBe` (Status 500 "error message") mapM_ test $ (WrappedApi (Proxy :: Proxy Delete), "Delete") : (WrappedApi (Proxy :: Proxy (Get '[JSON] ())), "Delete") :