on master help sign in
adding FdCacheSpec
commitaaaac60620da97543081c2c36104fe5464cda6e2 authorKazu Yamamoto <kazu@iij.ad.jp> dateMon 21 Oct 2013, 09:51 (13 years ago) parent4972df4
2 files changed+23
warp/test/FdCacheSpec.hs+22 warp/warp.cabal+1
warp/test/FdCacheSpec.hsnew file+22
@@ -0,0 +1,22 @@
1+module FdCacheSpec where
2+
3+import Data.IORef
4+import Network.Wai.Handler.Warp.FdCache
5+import System.Posix.IO (fdRead)
6+import System.Posix.Types (Fd(..))
7+import Test.Hspec
8+
9+main :: IO ()
10+main = hspec spec
11+
12+spec :: Spec
13+spec = describe "withFdCache" $ do
14+ it "clean up Fd" $ do
15+ ref <- newIORef (Fd (-1))
16+ withFdCache 30000000 $ \(Just mfc) -> do
17+ (fd,_) <- getFd mfc "warp.cabal"
18+ writeIORef ref fd
19+ nfd <- readIORef ref
20+ fdRead nfd 1 `shouldThrow` anyIOException
21+
22+
warp/warp.cabal+1
@@ -79,6 +79,7 @@ Test-Suite spec
7979 Main-Is: Spec.hs
8080 Other-modules: ConduitSpec
8181 ExceptionSpec
82+ FdCacheSpec
8283 MultiMapSpec
8384 PartialFileSpec
8485 ReadIntSpec