summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-03-18 00:18:00 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-03-18 00:18:00 +0400
commit70a172a43d5b34853289bbf57c3e5a168431a954 (patch)
treed47eef9c0c4957088b0454e063cd15d3dc28510f /tests
parent1c1208c2d66172963faa5422dd61204b1ca1fdf2 (diff)
Spec `getStatus` and notify `dependency`
Diffstat (limited to 'tests')
-rw-r--r--tests/Network/BitTorrent/Tracker/SessionSpec.hs32
1 files changed, 26 insertions, 6 deletions
diff --git a/tests/Network/BitTorrent/Tracker/SessionSpec.hs b/tests/Network/BitTorrent/Tracker/SessionSpec.hs
index 2abe7bc0..aa87919d 100644
--- a/tests/Network/BitTorrent/Tracker/SessionSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/SessionSpec.hs
@@ -1,7 +1,6 @@
1module Network.BitTorrent.Tracker.SessionSpec (spec) where 1module Network.BitTorrent.Tracker.SessionSpec (spec) where
2import Data.Default 2import Data.Default
3import Data.List as L 3import Data.List as L
4import Network.URI
5import Test.Hspec 4import Test.Hspec
6 5
7import Data.Torrent 6import Data.Torrent
@@ -10,15 +9,36 @@ import Network.BitTorrent.Tracker.List
10import Network.BitTorrent.Tracker.RPC 9import Network.BitTorrent.Tracker.RPC
11import Network.BitTorrent.Tracker.Session 10import Network.BitTorrent.Tracker.Session
12 11
13import Network.BitTorrent.Tracker.TestData 12import Config
14 13
14testSession :: (Manager -> Session -> IO ()) -> IO ()
15testSession action = do
16 t <- getTestTorrent
17 withManager def def $ \ m ->
18 withSession (idInfoHash (tInfoDict t)) (trackerList t) $ \ s ->
19 action m s
15 20
16spec :: Spec 21spec :: Spec
17spec = do 22spec = do
18 describe "Session" $ do 23 describe "Session" $ do
19 it "" $ do 24 it "start new session in paused state" $ do
20 withManager def def $ \ m -> do 25 testSession $ \ _ s -> do
21 s <- newSession def undefined 26 status <- getStatus s
27 status `shouldBe` Paused
28
29 describe "Query" $ do
30 it "change status after notify" $ do
31 testSession $ \ m s -> do
32 notify m s Started
33 status <- getStatus s
34 status `shouldBe` Running
35
36 notify m s Stopped
37 stopped <- getStatus s
38 stopped `shouldBe` Paused
39
40 it "return non-empty list of peers" $ do
41 testSession $ \ m s -> do
22 notify m s Started 42 notify m s Started
23 peers <- askPeers m s 43 peers <- askPeers m s
24 peers `shouldSatisfy` (not . L.null) \ No newline at end of file 44 peers `shouldSatisfy` (not . L.null)