From ec70fdc102b950a23aad5565a08f10ddb8ef10c7 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 18 Mar 2014 18:17:30 +0400 Subject: Test specs with empty tracker list too --- tests/Network/BitTorrent/Tracker/SessionSpec.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/Network/BitTorrent/Tracker/SessionSpec.hs b/tests/Network/BitTorrent/Tracker/SessionSpec.hs index aa87919d..27a9ae1e 100644 --- a/tests/Network/BitTorrent/Tracker/SessionSpec.hs +++ b/tests/Network/BitTorrent/Tracker/SessionSpec.hs @@ -1,4 +1,5 @@ module Network.BitTorrent.Tracker.SessionSpec (spec) where +import Control.Monad import Data.Default import Data.List as L import Test.Hspec @@ -11,24 +12,28 @@ import Network.BitTorrent.Tracker.Session import Config -testSession :: (Manager -> Session -> IO ()) -> IO () -testSession action = do +testSession :: Bool -> (Manager -> Session -> IO ()) -> IO () +testSession runEmpty action = do t <- getTestTorrent - withManager def def $ \ m -> + withManager def def $ \ m -> do withSession (idInfoHash (tInfoDict t)) (trackerList t) $ \ s -> action m s + when runEmpty $ do + withSession (idInfoHash (tInfoDict t)) def $ \ s -> + action m s + spec :: Spec spec = do describe "Session" $ do it "start new session in paused state" $ do - testSession $ \ _ s -> do + testSession True $ \ _ s -> do status <- getStatus s status `shouldBe` Paused describe "Query" $ do it "change status after notify" $ do - testSession $ \ m s -> do + testSession True $ \ m s -> do notify m s Started status <- getStatus s status `shouldBe` Running @@ -38,7 +43,7 @@ spec = do stopped `shouldBe` Paused it "return non-empty list of peers" $ do - testSession $ \ m s -> do + testSession False $ \ m s -> do notify m s Started peers <- askPeers m s peers `shouldSatisfy` (not . L.null) -- cgit v1.2.3