add a testcase to very that we reject invalid json bodies with HTTP status 400
commit90ea56534b6105780c97b77e23a165c9932f5759
authorAlp Mestanogullari <alpmestan@gmail.com>
dateTue 28 Oct 2014, 16:58 (12 years ago)
parent7ca6b26
src/Servant/Server.hs+1−1
@@ -36,7 +36,7 @@ toApplication ra request respond = do
3636data RouteMismatch =
3737 NotFound -- ^ the usual "not found" error
3838 | WrongMethod -- ^ a more informative "you just got the HTTP method wrong" error
39− | InvalidBody -- ^ an even more informative "you json request body wasn't valid" error
39+ | InvalidBody -- ^ an even more informative "your json request body wasn't valid" error
4040 deriving (Eq, Show)
4141
4242-- |
test/Servant/ServerSpec.hs+3
@@ -154,6 +154,9 @@ postSpec = do
154154 matchStatus = 201
155155 }
156156
157+ it "correctly rejects invalid request bodies with status 400" $ do
158+ post "/" "some invalid body" `shouldRespondWith` 400
159+
157160
158161type RawApi = "foo" :> Raw
159162rawApi :: Proxy RawApi