summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r--tests/Network/BitTorrent/Tracker/ListSpec.hs11
-rw-r--r--tests/Network/BitTorrent/Tracker/SessionSpec.hs4
2 files changed, 7 insertions, 8 deletions
diff --git a/tests/Network/BitTorrent/Tracker/ListSpec.hs b/tests/Network/BitTorrent/Tracker/ListSpec.hs
index 03379136..bba9d0e2 100644
--- a/tests/Network/BitTorrent/Tracker/ListSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/ListSpec.hs
@@ -17,7 +17,7 @@ uris = fmap (fromJust . parseURI . renderURI) [1..10 :: Int]
17 where 17 where
18 renderURI n = "http://" ++ show n ++ ".org" 18 renderURI n = "http://" ++ show n ++ ".org"
19 19
20list :: TrackerList URI 20list :: TrackerList ()
21list = trackerList def { tAnnounceList = Just [uris] } 21list = trackerList def { tAnnounceList = Just [uris] }
22 22
23spec :: Spec 23spec :: Spec
@@ -28,14 +28,13 @@ spec = do
28 list' `shouldSatisfy` (/= list) 28 list' `shouldSatisfy` (/= list)
29 29
30 it "traverseAll" $ do 30 it "traverseAll" $ do
31 xs <- traverseAll (\ uri -> if uri == L.last uris 31 xs <- traverseAll (\ (uri, _) -> if uri == L.last uris
32 then throwIO (GenericException "") 32 then throwIO (GenericException "")
33 else return uri { uriScheme = "udp://" }) list 33 else return ()) list
34 let udps = F.sum $ fmap (fromEnum . ("udp://" ==) . uriScheme) xs 34 return ()
35 udps `shouldBe` pred (L.length uris)
36 35
37 it "traverseTiers" $ do 36 it "traverseTiers" $ do
38 xs' <- traverseTiers (\ uri -> if uri == L.last uris then return uri 37 xs' <- traverseTiers (\ (uri, _) -> if uri == L.last uris then return ()
39 else throwIO (GenericException "")) list 38 else throwIO (GenericException "")) list
40 39
41 return () 40 return ()
diff --git a/tests/Network/BitTorrent/Tracker/SessionSpec.hs b/tests/Network/BitTorrent/Tracker/SessionSpec.hs
index 2c471752..72936ee7 100644
--- a/tests/Network/BitTorrent/Tracker/SessionSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/SessionSpec.hs
@@ -16,11 +16,11 @@ testSession :: Bool -> (Manager -> Session -> IO ()) -> IO ()
16testSession runEmpty action = do 16testSession runEmpty action = do
17 t <- getTestTorrent 17 t <- getTestTorrent
18 withManager def def $ \ m -> do 18 withManager def def $ \ m -> do
19 withSession (idInfoHash (tInfoDict t)) (trackerList t) $ \ s -> 19 withSession m (idInfoHash (tInfoDict t)) (trackerList t) $ \ s ->
20 action m s 20 action m s
21 21
22 when runEmpty $ do 22 when runEmpty $ do
23 withSession (idInfoHash (tInfoDict t)) def $ \ s -> 23 withSession m (idInfoHash (tInfoDict t)) def $ \ s ->
24 action m s 24 action m s
25 25
26spec :: Spec 26spec :: Spec