git.iko.soy/servant-quickcheck
on master help sign in
Fix #56

A bug where the request printed alongside a failure in notAllowedContainsAllowHeader was not the request causing the failure.

commit89c9170bdfce4b5975ce677ec9a22490ae8a5757 authorJoachim Desroches <joachim.desroches@epfl.ch> dateMon 27 Aug 2018, 18:12 (8 years ago) parent35c9862
1 file changed+7−6
src/Servant/QuickCheck/Internal/Predicates.hs+7−6
src/Servant/QuickCheck/Internal/Predicates.hs+7−6
@@ -189,14 +189,15 @@ getsHaveLastModifiedHeader
189189notAllowedContainsAllowHeader :: RequestPredicate
190190notAllowedContainsAllowHeader
191191 = RequestPredicate $ \req mgr -> do
192− resp <- mapM (flip httpLbs mgr) $ [ req { method = renderStdMethod m }
193− | m <- [minBound .. maxBound ]
194− , renderStdMethod m /= method req ]
195− case filter pred' resp of
196− (x:_) -> throw $ PredicateFailure "notAllowedContainsAllowHeader" (Just req) x
192+ let reqs = [ req { method = renderStdMethod m } | m <- [minBound .. maxBound]
193+ , renderStdMethod m /= method req ]
194+ resp <- mapM (flip httpLbs mgr) reqs
195+
196+ case filter pred' (zip reqs resp) of
197+ (x:_) -> throw $ PredicateFailure "notAllowedContainsAllowHeader" (Just $ fst x) (snd x)
197198 [] -> return resp
198199 where
199− pred' resp = responseStatus resp == status405 && not (hasValidHeader "Allow" go resp)
200+ pred' (_, resp) = responseStatus resp == status405 && not (hasValidHeader "Allow" go resp)
200201 where
201202 go x = all (\y -> isRight $ parseMethod $ SBSC.pack y)
202203 $ wordsBy (`elem` (", " :: [Char])) (SBSC.unpack x)