on master help sign in
better naming.
commit5b1092f3a97bc9f41d2d6fcef592ca8d0c189b0b authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 10 Jul 2019, 16:24 (7 years ago) parente3ad8e2
2 files changed+37−37
warp/test/ResponseSpec.hs+11−11 warp/test/RunSpec.hs+26−26
warp/test/ResponseSpec.hs+11−11
@@ -21,14 +21,14 @@ testRange :: S.ByteString -- ^ range value
2121 -> Maybe String -- ^ expected content-range value
2222 -> Spec
2323testRange range out crange = it title $ withApp defaultSettings app $ \port -> do
24− handle <- connectTo port
25− msWrite handle "GET / HTTP/1.0\r\n"
26− msWrite handle "Range: bytes="
27− msWrite handle range
28− msWrite handle "\r\n\r\n"
24+ ms <- connectTo port
25+ msWrite ms "GET / HTTP/1.0\r\n"
26+ msWrite ms "Range: bytes="
27+ msWrite ms range
28+ msWrite ms "\r\n\r\n"
2929 threadDelay 10000
30− bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ msRead handle 1024
31− msClose handle
30+ bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ msRead ms 1024
31+ msClose ms
3232 last bss `shouldBe` out
3333 let hs = mapMaybe toHeader bss
3434 lookup "Content-Range" hs `shouldBe` fmap ("bytes " ++) crange
@@ -47,11 +47,11 @@ testPartial :: Integer -- ^ file size
4747 -> String -- ^ expected output
4848 -> Spec
4949testPartial size offset count out = it title $ withApp defaultSettings app $ \port -> do
50− handle <- connectTo port
51− msWrite handle "GET / HTTP/1.0\r\n\r\n"
50+ ms <- connectTo port
51+ msWrite ms "GET / HTTP/1.0\r\n\r\n"
5252 threadDelay 10000
53− bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ msRead handle 1024
54− msClose handle
53+ bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ msRead ms 1024
54+ msClose ms
5555 out `shouldBe` last bss
5656 let hs = mapMaybe toHeader bss
5757 lookup "Content-Length" hs `shouldBe` Just (show $ length $ last bss)
warp/test/RunSpec.hs+26−26
@@ -169,9 +169,9 @@ runTerminateTest expected input = do
169169 ref <- I.newIORef Nothing
170170 let onExc _ = I.writeIORef ref . Just
171171 withApp (setOnException onExc defaultSettings) dummyApp $ \port -> do
172− handle <- connectTo port
173− msWrite handle input
174− msClose handle
172+ ms <- connectTo port
173+ msWrite ms input
174+ msClose ms
175175 threadDelay 1000
176176 res <- I.readIORef ref
177177 show res `shouldBe` show (Just expected)
@@ -243,12 +243,12 @@ spec = do
243243 liftIO $ I.writeIORef iheaders $ requestHeaders req
244244 f $ responseLBS status200 [] ""
245245 withApp defaultSettings app $ \port -> do
246− handle <- connectTo port
246+ ms <- connectTo port
247247 let input = S.concat
248248 [ "GET / HTTP/1.1\r\nfoo: bar\r\n baz\r\n\tbin\r\n\r\n"
249249 ]
250− msWrite handle input
251− msClose handle
250+ msWrite ms input
251+ msClose ms
252252 threadDelay 1000
253253 headers <- I.readIORef iheaders
254254 headers `shouldBe`
@@ -260,12 +260,12 @@ spec = do
260260 liftIO $ I.writeIORef iheaders $ requestHeaders req
261261 f $ responseLBS status200 [] ""
262262 withApp defaultSettings app $ \port -> do
263− handle <- connectTo port
263+ ms <- connectTo port
264264 let input = S.concat
265265 [ "GET / HTTP/1.1\r\nfoo:bar\r\n\r\n"
266266 ]
267− msWrite handle input
268− msClose handle
267+ msWrite ms input
268+ msClose ms
269269 threadDelay 1000
270270 headers <- I.readIORef iheaders
271271 headers `shouldBe`
@@ -282,15 +282,15 @@ spec = do
282282 atomically $ modifyTVar countVar (+ 1)
283283 f $ responseLBS status200 [] ""
284284 withApp defaultSettings app $ \port -> do
285− handle <- connectTo port
285+ ms <- connectTo port
286286 let input = S.concat
287287 [ "POST / HTTP/1.1\r\nTransfer-Encoding: Chunked\r\n\r\n"
288288 , "c\r\nHello World\n\r\n3\r\nBye\r\n0\r\n\r\n"
289289 , "POST / HTTP/1.1\r\nTransfer-Encoding: Chunked\r\n\r\n"
290290 , "b\r\nHello World\r\n0\r\n\r\n"
291291 ]
292− msWrite handle input
293− msClose handle
292+ msWrite ms input
293+ msClose ms
294294 atomically $ do
295295 count <- readTVar countVar
296296 check $ count == 2
@@ -308,13 +308,13 @@ spec = do
308308 atomically $ modifyTVar countVar (+ 1)
309309 f $ responseLBS status200 [] ""
310310 withApp defaultSettings app $ \port -> do
311− handle <- connectTo port
311+ ms <- connectTo port
312312 let input = concat $ replicate 2 $
313313 ["POST / HTTP/1.1\r\nTransfer-Encoding: Chunked\r\n\r\n"] ++
314314 (replicate 50 "5\r\n12345\r\n") ++
315315 ["0\r\n\r\n"]
316− mapM_ (msWrite handle) input
317− msClose handle
316+ mapM_ (msWrite ms) input
317+ msClose ms
318318 atomically $ do
319319 count <- readTVar countVar
320320 check $ count == 2
@@ -331,15 +331,15 @@ spec = do
331331 atomically $ modifyTVar countVar (+ 1)
332332 f $ responseLBS status200 [] ""
333333 withApp defaultSettings app $ \port -> do
334− handle <- connectTo port
334+ ms <- connectTo port
335335 let input = S.concat
336336 [ "POST / HTTP/1.1\r\nTransfer-Encoding: Chunked\r\n\r\n"
337337 , "c\r\nHello World\n\r\n3\r\nBye\r\n0\r\n"
338338 , "POST / HTTP/1.1\r\nTransfer-Encoding: Chunked\r\n\r\n"
339339 , "b\r\nHello World\r\n0\r\n\r\n"
340340 ]
341− mapM_ (msWrite handle) $ map S.singleton $ S.unpack input
342− msClose handle
341+ mapM_ (msWrite ms) $ map S.singleton $ S.unpack input
342+ msClose ms
343343 atomically $ do
344344 count <- readTVar countVar
345345 check $ count == 2
@@ -364,16 +364,16 @@ spec = do
364364 let bs1 = S.replicate 2048 88
365365 bs2 = "This is short"
366366 bs = S.append bs1 bs2
367− handle <- connectTo port
368− msWrite handle "POST / HTTP/1.1\r\n"
369− msWrite handle "content-length: "
370− msWrite handle $ S8.pack $ show $ S.length bs
371− msWrite handle "\r\n\r\n"
367+ ms <- connectTo port
368+ msWrite ms "POST / HTTP/1.1\r\n"
369+ msWrite ms "content-length: "
370+ msWrite ms $ S8.pack $ show $ S.length bs
371+ msWrite ms "\r\n\r\n"
372372 threadDelay 100000
373− msWrite handle bs1
373+ msWrite ms bs1
374374 threadDelay 100000
375− msWrite handle bs2
376− msClose handle
375+ msWrite ms bs2
376+ msClose ms
377377 threadDelay 5000000
378378 front <- I.readIORef ifront
379379 S.concat (front []) `shouldBe` bs