@@ -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+