diff options
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs | 35 |
1 files changed, 35 insertions, 0 deletions
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 @@ | |||
1 | module Network.BitTorrent.Tracker.RPC.HTTPSpec (spec) where | ||
2 | |||
3 | import Control.Monad | ||
4 | import Control.Monad.Trans | ||
5 | import Control.Monad.Trans.Resource | ||
6 | import Data.Default | ||
7 | import Data.List as L | ||
8 | import Data.Maybe | ||
9 | import Network.URI | ||
10 | import Test.Hspec | ||
11 | |||
12 | import Network.BitTorrent.Tracker.RPC.MessageSpec hiding (spec) | ||
13 | import Network.BitTorrent.Tracker.RPC.HTTP | ||
14 | |||
15 | |||
16 | trackerURIs :: [URI] | ||
17 | trackerURIs = | ||
18 | [ fromJust $ parseURI "http://announce.opensharing.org:2710/announce" | ||
19 | , fromJust $ parseURI "http://exodus.desync.com/announce" | ||
20 | ] | ||
21 | |||
22 | spec :: Spec | ||
23 | spec = do | ||
24 | forM_ trackerURIs $ \ uri -> | ||
25 | context (show uri) $ do | ||
26 | describe "announce" $ do | ||
27 | it "have valid response" $ do | ||
28 | q <- arbitrarySample | ||
29 | info <- runResourceT $ connect uri >>= announce q | ||
30 | validateInfo q info | ||
31 | |||
32 | describe "scrape" $ do | ||
33 | it "have valid response" $ do | ||
34 | xs <- runResourceT $ connect uri >>= scrape [def] | ||
35 | L.length xs `shouldSatisfy` (>= 1) | ||