summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-03-18 18:17:30 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-03-18 18:17:30 +0400
commitec70fdc102b950a23aad5565a08f10ddb8ef10c7 (patch)
treeed6750d8df776e4f736bf4cdee6e21c6df5d607e /tests/Network/BitTorrent/Tracker
parentcab485585f87f73274026106235edae7765dd72e (diff)
Test specs with empty tracker list too
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r--tests/Network/BitTorrent/Tracker/SessionSpec.hs17
1 files changed, 11 insertions, 6 deletions
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 @@
1module Network.BitTorrent.Tracker.SessionSpec (spec) where 1module Network.BitTorrent.Tracker.SessionSpec (spec) where
2import Control.Monad
2import Data.Default 3import Data.Default
3import Data.List as L 4import Data.List as L
4import Test.Hspec 5import Test.Hspec
@@ -11,24 +12,28 @@ import Network.BitTorrent.Tracker.Session
11 12
12import Config 13import Config
13 14
14testSession :: (Manager -> Session -> IO ()) -> IO () 15testSession :: Bool -> (Manager -> Session -> IO ()) -> IO ()
15testSession action = do 16testSession runEmpty action = do
16 t <- getTestTorrent 17 t <- getTestTorrent
17 withManager def def $ \ m -> 18 withManager def def $ \ m -> do
18 withSession (idInfoHash (tInfoDict t)) (trackerList t) $ \ s -> 19 withSession (idInfoHash (tInfoDict t)) (trackerList t) $ \ s ->
19 action m s 20 action m s
20 21
22 when runEmpty $ do
23 withSession (idInfoHash (tInfoDict t)) def $ \ s ->
24 action m s
25
21spec :: Spec 26spec :: Spec
22spec = do 27spec = do
23 describe "Session" $ do 28 describe "Session" $ do
24 it "start new session in paused state" $ do 29 it "start new session in paused state" $ do
25 testSession $ \ _ s -> do 30 testSession True $ \ _ s -> do
26 status <- getStatus s 31 status <- getStatus s
27 status `shouldBe` Paused 32 status `shouldBe` Paused
28 33
29 describe "Query" $ do 34 describe "Query" $ do
30 it "change status after notify" $ do 35 it "change status after notify" $ do
31 testSession $ \ m s -> do 36 testSession True $ \ m s -> do
32 notify m s Started 37 notify m s Started
33 status <- getStatus s 38 status <- getStatus s
34 status `shouldBe` Running 39 status `shouldBe` Running
@@ -38,7 +43,7 @@ spec = do
38 stopped `shouldBe` Paused 43 stopped `shouldBe` Paused
39 44
40 it "return non-empty list of peers" $ do 45 it "return non-empty list of peers" $ do
41 testSession $ \ m s -> do 46 testSession False $ \ m s -> do
42 notify m s Started 47 notify m s Started
43 peers <- askPeers m s 48 peers <- askPeers m s
44 peers `shouldSatisfy` (not . L.null) 49 peers `shouldSatisfy` (not . L.null)