on master help sign in
adding FdCacheSpec
aaaac60Kazu Yamamoto
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
79 Main-Is: Spec.hs
79 Main-Is: Spec.hs
80 Other-modules: ConduitSpec
80 Other-modules: ConduitSpec
81 ExceptionSpec
81 ExceptionSpec
82+ FdCacheSpec
82 MultiMapSpec
83 MultiMapSpec
83 PartialFileSpec
84 PartialFileSpec
84 ReadIntSpec
85 ReadIntSpec