summaryrefslogtreecommitdiff
path: root/tests/Network
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-26 21:09:46 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-26 21:09:46 +0400
commit8d094413e88b57dc71f60fb48631fe43174dc696 (patch)
treee1da3481ca6342fbc5cc646a595de5699bc8e310 /tests/Network
parentac56fc5a2111ff0a5fcb97566a15e598b53b62bb (diff)
Check udp tracker manager options
Diffstat (limited to 'tests/Network')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
index acc60e09..bfe0c92f 100644
--- a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
@@ -1,6 +1,7 @@
1{-# LANGUAGE RecordWildCards #-} 1{-# LANGUAGE RecordWildCards #-}
2module Network.BitTorrent.Tracker.RPC.UDPSpec (spec, rpcOpts) where 2module Network.BitTorrent.Tracker.RPC.UDPSpec (spec, rpcOpts) where
3import Control.Concurrent.Async 3import Control.Concurrent.Async
4import Control.Exception
4import Control.Monad 5import Control.Monad
5import Data.Default 6import Data.Default
6import Data.List as L 7import Data.List as L
@@ -40,8 +41,32 @@ isTimeoutExpired :: RpcException -> Bool
40isTimeoutExpired (TimeoutExpired _) = True 41isTimeoutExpired (TimeoutExpired _) = True
41isTimeoutExpired _ = False 42isTimeoutExpired _ = False
42 43
44isSomeException :: SomeException -> Bool
45isSomeException _ = True
46
43spec :: Spec 47spec :: Spec
44spec = parallel $ do 48spec = parallel $ do
49 describe "newManager" $ do
50 it "should throw exception on zero optMaxPacketSize" $ do
51 let opts = def { optMaxPacketSize = 0 }
52 newManager opts `shouldThrow` isSomeException
53
54 it "should throw exception on zero optMinTimout" $ do
55 let opts = def { optMinTimeout = 0 }
56 newManager opts `shouldThrow` isSomeException
57
58 it "should throw exception on zero optMaxTimeout" $ do
59 let opts = def { optMaxTimeout = 0 }
60 newManager opts `shouldThrow` isSomeException
61
62 it "should throw exception on maxTimeout < minTimeout" $ do
63 let opts = def { optMinTimeout = 2, optMaxTimeout = 1 }
64 newManager opts `shouldThrow` isSomeException
65
66 it "should throw exception on optMultiplier" $ do
67 let opts = def { optMultiplier = 0 }
68 newManager opts `shouldThrow` isSomeException
69
45 forM_ (L.filter isUdpTracker trackers) $ \ TrackerEntry {..} -> 70 forM_ (L.filter isUdpTracker trackers) $ \ TrackerEntry {..} ->
46 context trackerName $ do 71 context trackerName $ do
47 72