From f3978c457103b476d8658364a8c19e1ecae287dd Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 27 Feb 2014 16:32:29 +0400 Subject: Test UnrecognizedProtocol exceptions --- tests/Network/BitTorrent/Tracker/RPCSpec.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests/Network') 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 { optUdpRPC = UDP.rpcOpts } +isUnrecognizedProtocol :: String -> RpcException -> Bool +isUnrecognizedProtocol x (UnrecognizedProtocol scheme) = x == scheme +isUnrecognizedProtocol _ _ = False + spec :: Spec spec = do describe "Manager" $ do @@ -39,11 +43,16 @@ spec = do describe "RPC" $ do describe "announce" $ do it "must fail on bad uri scheme" $ do - pending + withManager rpcOpts def $ \ mgr -> do + q <- arbitrarySample + announce mgr "magnet://foo.bar" q + `shouldThrow` isUnrecognizedProtocol "magnet:" describe "scrape" $ do it "must fail on bad uri scheme" $ do - pending + withManager rpcOpts def $ \ mgr -> do + scrape mgr "magnet://foo.bar" [] + `shouldThrow` isUnrecognizedProtocol "magnet:" forM_ trackers $ \ TrackerEntry {..} -> context trackerName $ do -- cgit v1.2.3