From 541ffe4b36e53dc57926ef70f1a41caf0c114b58 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sun, 1 Dec 2013 14:28:58 +0400 Subject: Add basic tests for tracker HTTP rpc --- tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs diff --git a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs new file mode 100644 index 00000000..141a2597 --- /dev/null +++ b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs @@ -0,0 +1,35 @@ +module Network.BitTorrent.Tracker.RPC.HTTPSpec (spec) where + +import Control.Monad +import Control.Monad.Trans +import Control.Monad.Trans.Resource +import Data.Default +import Data.List as L +import Data.Maybe +import Network.URI +import Test.Hspec + +import Network.BitTorrent.Tracker.RPC.MessageSpec hiding (spec) +import Network.BitTorrent.Tracker.RPC.HTTP + + +trackerURIs :: [URI] +trackerURIs = + [ fromJust $ parseURI "http://announce.opensharing.org:2710/announce" + , fromJust $ parseURI "http://exodus.desync.com/announce" + ] + +spec :: Spec +spec = do + forM_ trackerURIs $ \ uri -> + context (show uri) $ do + describe "announce" $ do + it "have valid response" $ do + q <- arbitrarySample + info <- runResourceT $ connect uri >>= announce q + validateInfo q info + + describe "scrape" $ do + it "have valid response" $ do + xs <- runResourceT $ connect uri >>= scrape [def] + L.length xs `shouldSatisfy` (>= 1) -- cgit v1.2.3