diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-26 21:09:46 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-26 21:09:46 +0400 |
commit | 8d094413e88b57dc71f60fb48631fe43174dc696 (patch) | |
tree | e1da3481ca6342fbc5cc646a595de5699bc8e310 /tests | |
parent | ac56fc5a2111ff0a5fcb97566a15e598b53b62bb (diff) |
Check udp tracker manager options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | 25 |
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 #-} |
2 | module Network.BitTorrent.Tracker.RPC.UDPSpec (spec, rpcOpts) where | 2 | module Network.BitTorrent.Tracker.RPC.UDPSpec (spec, rpcOpts) where |
3 | import Control.Concurrent.Async | 3 | import Control.Concurrent.Async |
4 | import Control.Exception | ||
4 | import Control.Monad | 5 | import Control.Monad |
5 | import Data.Default | 6 | import Data.Default |
6 | import Data.List as L | 7 | import Data.List as L |
@@ -40,8 +41,32 @@ isTimeoutExpired :: RpcException -> Bool | |||
40 | isTimeoutExpired (TimeoutExpired _) = True | 41 | isTimeoutExpired (TimeoutExpired _) = True |
41 | isTimeoutExpired _ = False | 42 | isTimeoutExpired _ = False |
42 | 43 | ||
44 | isSomeException :: SomeException -> Bool | ||
45 | isSomeException _ = True | ||
46 | |||
43 | spec :: Spec | 47 | spec :: Spec |
44 | spec = parallel $ do | 48 | spec = 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 | ||