summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-27 16:32:29 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-27 16:32:29 +0400
commitf3978c457103b476d8658364a8c19e1ecae287dd (patch)
tree3d7eeff1607df11a4bd3b18b24727e96af3e8bb9 /tests/Network/BitTorrent/Tracker
parent7b7d94c73686226db26e1cf79f7783d09fa58cf7 (diff)
Test UnrecognizedProtocol exceptions
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPCSpec.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPCSpec.hs b/tests/Network/BitTorrent/Tracker/RPCSpec.hs
index dd91c3ce..31a04978 100644
--- a/tests/Network/BitTorrent/Tracker/RPCSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/RPCSpec.hs
@@ -24,6 +24,10 @@ rpcOpts = def
24 { optUdpRPC = UDP.rpcOpts 24 { optUdpRPC = UDP.rpcOpts
25 } 25 }
26 26
27isUnrecognizedProtocol :: String -> RpcException -> Bool
28isUnrecognizedProtocol x (UnrecognizedProtocol scheme) = x == scheme
29isUnrecognizedProtocol _ _ = False
30
27spec :: Spec 31spec :: Spec
28spec = do 32spec = do
29 describe "Manager" $ do 33 describe "Manager" $ do
@@ -39,11 +43,16 @@ spec = do
39 describe "RPC" $ do 43 describe "RPC" $ do
40 describe "announce" $ do 44 describe "announce" $ do
41 it "must fail on bad uri scheme" $ do 45 it "must fail on bad uri scheme" $ do
42 pending 46 withManager rpcOpts def $ \ mgr -> do
47 q <- arbitrarySample
48 announce mgr "magnet://foo.bar" q
49 `shouldThrow` isUnrecognizedProtocol "magnet:"
43 50
44 describe "scrape" $ do 51 describe "scrape" $ do
45 it "must fail on bad uri scheme" $ do 52 it "must fail on bad uri scheme" $ do
46 pending 53 withManager rpcOpts def $ \ mgr -> do
54 scrape mgr "magnet://foo.bar" []
55 `shouldThrow` isUnrecognizedProtocol "magnet:"
47 56
48 forM_ trackers $ \ TrackerEntry {..} -> 57 forM_ trackers $ \ TrackerEntry {..} ->
49 context trackerName $ do 58 context trackerName $ do