on master help sign in
Moar TVars
commit6d82e1d8829c66790b58e25c111964c803cbca55 authorMichael Snoyman <michael@snoyman.com> dateSun 31 Mar 2019, 19:03 (8 years ago) parent51aeef6
1 file changed+5−1
warp/test/RunSpec.hs+5−1
warp/test/RunSpec.hs+5−1
@@ -241,10 +241,12 @@ spec = do
241241
242242 describe "chunked bodies" $ do
243243 it "works" $ do
244+ countVar <- newTVarIO (0 :: Int)
244245 ifront <- I.newIORef id
245246 let app req f = do
246247 bss <- consumeBody $ requestBody req
247248 liftIO $ I.atomicModifyIORef ifront $ \front -> (front . (S.concat bss:), ())
249+ atomically $ modifyTVar countVar (+ 1)
248250 f $ responseLBS status200 [] ""
249251 withApp defaultSettings app $ \port -> do
250252 handle <- connectTo "127.0.0.1" port
@@ -257,7 +259,9 @@ spec = do
257259 hPutStr handle input
258260 hFlush handle
259261 hClose handle
260− threadDelay 1000
262+ atomically $ do
263+ count <- readTVar countVar
264+ check $ count == 2
261265 front <- I.readIORef ifront
262266 front [] `shouldBe`
263267 [ "Hello World\nBye"