Merge pull request #4 from zerobuzz/test-case-for-servant-issue-3
This test case reproduces servant issue #3.
This commit is contained in:
commit
1e6fbd111d
1 changed files with 9 additions and 2 deletions
|
@ -189,19 +189,26 @@ queryParamSpec = do
|
||||||
name = "ALICE"
|
name = "ALICE"
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostApi = ReqBody Person :> Post Integer
|
type PostApi =
|
||||||
|
ReqBody Person :> Post Integer
|
||||||
|
:<|> "bla" :> ReqBody Person :> Post Integer
|
||||||
postApi :: Proxy PostApi
|
postApi :: Proxy PostApi
|
||||||
postApi = Proxy
|
postApi = Proxy
|
||||||
|
|
||||||
postSpec :: Spec
|
postSpec :: Spec
|
||||||
postSpec = do
|
postSpec = do
|
||||||
describe "Servant.API.Post and .ReqBody" $ 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
|
it "allows to POST a Person" $ do
|
||||||
post "/" (encode alice) `shouldRespondWith` "42"{
|
post "/" (encode alice) `shouldRespondWith` "42"{
|
||||||
matchStatus = 201
|
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
|
it "correctly rejects invalid request bodies with status 400" $ do
|
||||||
post "/" "some invalid body" `shouldRespondWith` 400
|
post "/" "some invalid body" `shouldRespondWith` 400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue