yesod-test 0.3.3.1 → 0.3.3.2
raw patch · 2 files changed
+26/−19 lines, 2 filesdep ~HUnitdep ~attoparsecdep ~blaze-html
Dependency ranges changed: HUnit, attoparsec, blaze-html, blaze-markup, html-conduit, persistent, transformers, wai, wai-test, xml-conduit, xml-types
Files
- Yesod/Test.hs +14/−7
- yesod-test.cabal +12/−12
Yesod/Test.hs view
@@ -33,7 +33,7 @@ -- add values, add files, lookup fields by label and find the current -- nonce value and add it to your request too. -- - post, post_, get, get_, doRequest,+ post, post_, get, get_, doRequest, doRequestHeaders, byName, fileByName, -- | Yesod cat auto generate field ids, so you are never sure what@@ -363,9 +363,14 @@ get_ :: BS8.ByteString -> OneSpec conn () get_ = flip get $ return () --- | General interface to performing requests, letting you specify the request method and extra headers.+-- | General interface to performing requests, letting you specify the request method doRequest :: H.Method -> BS8.ByteString -> RequestBuilder a -> OneSpec conn ()-doRequest method url paramsBuild = do+doRequest method url paramsBuild = doRequestHeaders method url [] paramsBuild++-- | General interface to performing requests, allowing you to add extra+-- headers as well as letting you specify the request method.+doRequestHeaders :: H.Method -> BS8.ByteString -> [H.Header] -> RequestBuilder a -> OneSpec conn ()+doRequestHeaders method url extrahead paramsBuild = do OneSpecData app conn oldCookies mRes <- ST.get -- expire cookies and filter them for the current path. TODO: support max age@@ -398,10 +403,11 @@ boundary = "*******noneedtomakethisrandom" separator = BS8.concat ["--", BS8.pack boundary, "\r\n"] makeMultipart cookies parts =- flip SRequest (BSL8.fromChunks [multiPartBody parts]) $ mkRequest+ flip SRequest (BSL8.fromChunks [multiPartBody parts]) $ mkRequest $ [ ("Cookie", Builder.toByteString $ Cookie.renderCookies [(Cookie.setCookieName c, Cookie.setCookieValue c) | c <- map snd $ M.toList cookies])- , ("Content-Type", BS8.pack $ "multipart/form-data; boundary=" ++ boundary)]+ , ("Content-Type", BS8.pack $ "multipart/form-data; boundary=" ++ boundary)+ ] ++ extrahead multiPartBody parts = BS8.concat $ separator : [BS8.concat [multipartPart p, separator] | p <- parts] multipartPart (ReqPlainPart k v) = BS8.concat@@ -416,10 +422,11 @@ , BS8.concat $ BSL8.toChunks bytes, "\r\n"] -- For building the regular non-multipart requests- makeSinglepart cookies parts = SRequest (mkRequest + makeSinglepart cookies parts = SRequest (mkRequest $ [ ("Cookie", Builder.toByteString $ Cookie.renderCookies [(Cookie.setCookieName c, Cookie.setCookieValue c) | c <- map snd $ M.toList cookies])- , ("Content-Type", "application/x-www-form-urlencoded")]) $+ , ("Content-Type", "application/x-www-form-urlencoded")+ ] ++ extrahead) $ BSL8.fromChunks $ return $ TE.encodeUtf8 $ T.intercalate "&" $ map singlepartPart parts singlepartPart (ReqFilePart _ _ _ _) = ""
yesod-test.cabal view
@@ -1,5 +1,5 @@ name: yesod-test-version: 0.3.3.1+version: 0.3.3.2 license: MIT license-file: LICENSE author: Nubis <nubis@woobiz.com.ar>@@ -15,24 +15,24 @@ library build-depends: base >= 4.3 && < 5- , attoparsec >= 0.10 && < 0.11- , persistent >= 1.0 && < 1.2- , transformers >= 0.2.2 && < 0.4- , wai >= 1.3 && < 1.4- , wai-test >= 1.3 && < 1.4+ , attoparsec >= 0.10+ , persistent >= 1.0+ , transformers >= 0.2.2+ , wai >= 1.3+ , wai-test >= 1.3 , network >= 2.2 , http-types >= 0.7- , HUnit >= 1.2 && < 1.3+ , HUnit >= 1.2 , hspec >= 1.4 , bytestring >= 0.9 , case-insensitive >= 0.2 , text- , xml-conduit >= 1.0 && < 1.1- , xml-types >= 0.3 && < 0.4+ , xml-conduit >= 1.0+ , xml-types >= 0.3 , containers- , html-conduit >= 0.1 && < 0.2- , blaze-html >= 0.5 && < 0.6- , blaze-markup >= 0.5.1 && < 0.6+ , html-conduit >= 0.1+ , blaze-html >= 0.5+ , blaze-markup >= 0.5.1 , pool-conduit , monad-control , time