Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make a start on testing ByteString

  • Loading branch information...
commit b415a365ed88272502e52325c8f3d68c28dc8600 1 parent 4fa0e24
@hsenag hsenag authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 test/httpTests.hs
View
10 test/httpTests.hs
@@ -15,6 +15,7 @@ import qualified Httpd
import Network.Browser
import Network.HTTP
+import Network.HTTP.Base
import Network.HTTP.Auth
import Network.HTTP.Headers
import Network.Stream (Result)
@@ -36,6 +37,14 @@ basicGetRequest = do
body <- getResponseBody response
assertEqual "Receiving expected response" "It works." body
+basicGetRequestLBS :: (?testUrl :: ServerAddress) => Assertion
+basicGetRequestLBS = do
+ response <- simpleHTTP (mkRequest GET (fromJust (parseURI (?testUrl ("/basic/get")))))
+ code <- getResponseCode response
+ assertEqual "HTTP status code" (2, 0, 0) code
+ body <- getResponseBody response
+ assertEqual "Receiving expected response" (BL.pack "It works.") body
+
basicHeadRequest :: (?testUrl :: ServerAddress) => Assertion
basicHeadRequest = do
response <- simpleHTTP (headRequest (?testUrl "/basic/head"))
@@ -497,6 +506,7 @@ maybeTestGroup False name _ = testGroup name []
basicTests =
testGroup "Basic tests"
[ testCase "Basic GET request" basicGetRequest
+ , testCase "Basic GET request (lazy bytestring)" basicGetRequestLBS
, testCase "Network.HTTP example code" basicExample
, testCase "Secure GET request" secureGetRequest
, testCase "Basic POST request" basicPostRequest
Please sign in to comment.
Something went wrong with that request. Please try again.