Skip to content

Commit

Permalink
Add test for readRequestBody hang issue snapframework/snap-core#200
Browse files Browse the repository at this point in the history
  • Loading branch information
imalsogreg committed Jun 25, 2014
1 parent 26818c9 commit 7fb91c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions test/suite/Snap/Snaplet/Test/Tests.hs
Expand Up @@ -5,6 +5,9 @@ module Snap.Snaplet.Test.Tests


------------------------------------------------------------------------------
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (race)
import Control.Monad (join)
import qualified Data.Map as Map
import Test.Framework
import Test.Framework.Providers.HUnit
Expand All @@ -26,6 +29,7 @@ tests = testGroup "Snap.Snaplet.Test"
, testEvalHandler'
, testFailingEvalHandler
, testFailingGetSnaplet
-- , readRequestBodyHangIssue
]

testRunHandler :: Test
Expand Down Expand Up @@ -91,3 +95,15 @@ testFailingGetSnaplet = testCase "getSnaplet failing" assertGetSnaplet
case init of
Left _ -> assertBool "" True
Right _ -> assertFailure "Should have failed in initializer"


readRequestBodyHangIssue :: Test
readRequestBodyHangIssue = testCase "readRequestBody doesn't hang" assertReadRqBody
where
assertReadRqBody = do let hdl = readRequestBody 5000 >>= writeLBS
res <- race
(threadDelay 1000000)
(runHandler Nothing (ST.get "" Map.empty) hdl appInit)
either (assertFailure . ("readRequestBody timeout" ++) . show)
(either (assertFailure . show) ST.assertSuccess) res

12 changes: 6 additions & 6 deletions test/suite/TestSuite.hs
Expand Up @@ -59,13 +59,13 @@ main = do
testGroup "snap" [ --internalServerTests

Snap.Snaplet.Auth.Tests.tests
-- , Snap.Snaplet.Test.Tests.tests
, Snap.Snaplet.Test.Tests.tests

, Snap.Snaplet.Heist.Tests.heistTests
, Snap.Snaplet.Config.Tests.configTests
, Snap.Snaplet.Internal.RST.Tests.tests
, Snap.Snaplet.Internal.LensT.Tests.tests
, Snap.Snaplet.Internal.Lensed.Tests.tests
, Snap.Snaplet.Heist.Tests.heistTests
, Snap.Snaplet.Config.Tests.configTests
, Snap.Snaplet.Internal.RST.Tests.tests
, Snap.Snaplet.Internal.LensT.Tests.tests
, Snap.Snaplet.Internal.Lensed.Tests.tests
]


Expand Down

0 comments on commit 7fb91c0

Please sign in to comment.