From 8d094413e88b57dc71f60fb48631fe43174dc696 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 26 Feb 2014 21:09:46 +0400 Subject: Check udp tracker manager options --- tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/Network/BitTorrent') 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 @@ {-# LANGUAGE RecordWildCards #-} module Network.BitTorrent.Tracker.RPC.UDPSpec (spec, rpcOpts) where import Control.Concurrent.Async +import Control.Exception import Control.Monad import Data.Default import Data.List as L @@ -40,8 +41,32 @@ isTimeoutExpired :: RpcException -> Bool isTimeoutExpired (TimeoutExpired _) = True isTimeoutExpired _ = False +isSomeException :: SomeException -> Bool +isSomeException _ = True + spec :: Spec spec = parallel $ do + describe "newManager" $ do + it "should throw exception on zero optMaxPacketSize" $ do + let opts = def { optMaxPacketSize = 0 } + newManager opts `shouldThrow` isSomeException + + it "should throw exception on zero optMinTimout" $ do + let opts = def { optMinTimeout = 0 } + newManager opts `shouldThrow` isSomeException + + it "should throw exception on zero optMaxTimeout" $ do + let opts = def { optMaxTimeout = 0 } + newManager opts `shouldThrow` isSomeException + + it "should throw exception on maxTimeout < minTimeout" $ do + let opts = def { optMinTimeout = 2, optMaxTimeout = 1 } + newManager opts `shouldThrow` isSomeException + + it "should throw exception on optMultiplier" $ do + let opts = def { optMultiplier = 0 } + newManager opts `shouldThrow` isSomeException + forM_ (L.filter isUdpTracker trackers) $ \ TrackerEntry {..} -> context trackerName $ do -- cgit v1.2.3