From f4f59ed1906aa9e7f4affc8ef0896355b2e33c8b Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Fri, 28 Feb 2014 20:55:33 +0400 Subject: Spec: that if http tracker not responding... --- tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/Network') diff --git a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs index 2a00c96c..65f58911 100644 --- a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs +++ b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs @@ -26,6 +26,10 @@ isUnrecognizedScheme :: RpcException -> Bool isUnrecognizedScheme (RequestFailed _) = True isUnrecognizedScheme _ = False +isNotResponding :: RpcException -> Bool +isNotResponding (RequestFailed _) = True +isNotResponding _ = False + spec :: Spec spec = parallel $ do describe "Manager" $ do @@ -68,7 +72,10 @@ spec = parallel $ do validateInfo q info else do it "should fail with RequestFailed" $ do - pending + withManager def $ \ mgr -> do + q <- arbitrarySample + announce mgr trackerURI q + `shouldThrow` isNotResponding describe "scrape" $ do if tryScraping @@ -80,3 +87,9 @@ spec = parallel $ do else do it "should fail with ScrapelessTracker" $ do pending + + when (not tryAnnounce) $ do + it "should fail with RequestFailed" $ do + withManager def $ \ mgr -> do + scrape mgr trackerURI [def] + `shouldThrow` isNotResponding -- cgit v1.2.3