This test case reproduces servant issue #3.

This commit is contained in:
Alp Mestanogullari 2015-01-01 21:21:25 +01:00 committed by Matthias Fischmann
commit aaf448f3fe
2 changed files with 12 additions and 2 deletions

View File

@ -29,6 +29,9 @@ import Servant.Server.Internal
-- > where listAllBooks = ...
-- > postBook book = ...
-- >
-- > myApi :: Proxy MyApi
-- > myApi = Proxy
-- >
-- > app :: Application
-- > app = serve myApi server
-- >

View File

@ -189,19 +189,26 @@ queryParamSpec = do
name = "ALICE"
}
type PostApi = ReqBody Person :> Post Integer
type PostApi =
ReqBody Person :> Post Integer
:<|> "bla" :> ReqBody Person :> Post Integer
postApi :: Proxy PostApi
postApi = Proxy
postSpec :: Spec
postSpec = do
describe "Servant.API.Post and .ReqBody" $ do
with (return (serve postApi (return . age))) $ do
with (return (serve postApi (return . age :<|> return . age))) $ do
it "allows to POST a Person" $ do
post "/" (encode alice) `shouldRespondWith` "42"{
matchStatus = 201
}
it "allows alternative routes if all have request bodies" $ do
post "/bla" (encode alice) `shouldRespondWith` "42"{
matchStatus = 201
}
it "correctly rejects invalid request bodies with status 400" $ do
post "/" "some invalid body" `shouldRespondWith` 400