diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-04-03 00:36:33 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-04-03 00:36:33 +0400 |
commit | 14a90a6848b4fb39cd61459746ca8ea136adffb0 (patch) | |
tree | 8dfbef004437265f87df33a65b2b2049f38d6576 /tests/Network/BitTorrent/Tracker | |
parent | 39d73a4e40fede12f41de6e2a2f682893809b88b (diff) |
[Tracker] Update spec
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r-- | tests/Network/BitTorrent/Tracker/ListSpec.hs | 11 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Tracker/SessionSpec.hs | 4 |
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 | ||
20 | list :: TrackerList URI | 20 | list :: TrackerList () |
21 | list = trackerList def { tAnnounceList = Just [uris] } | 21 | list = trackerList def { tAnnounceList = Just [uris] } |
22 | 22 | ||
23 | spec :: Spec | 23 | spec :: 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 () | |||
16 | testSession runEmpty action = do | 16 | testSession 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 | ||
26 | spec :: Spec | 26 | spec :: Spec |