diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-01 14:28:58 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-01 14:28:58 +0400 |
commit | 541ffe4b36e53dc57926ef70f1a41caf0c114b58 (patch) | |
tree | 511a3036cfa27d2ac057f34b3ffe3e0a3b616068 /tests/Network/BitTorrent/Tracker | |
parent | 1188f4bcfccf578ab9bec286108ad3c4e8296b13 (diff) |
Add basic tests for tracker HTTP rpc
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-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) | ||