diff options
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs | 12 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | 10 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPCSpec.hs | 21 | ||||
-rw-r--r-- | tests/Readme.md | 1 |
4 files changed, 30 insertions, 14 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs index eb549516..81c4fae0 100644 --- a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs +++ b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs | |||
@@ -24,11 +24,13 @@ spec = do | |||
24 | context (show uri) $ do | 24 | context (show uri) $ do |
25 | describe "announce" $ do | 25 | describe "announce" $ do |
26 | it "have valid response" $ do | 26 | it "have valid response" $ do |
27 | q <- arbitrarySample | 27 | withManager def $ \ mgr -> do |
28 | info <- runResourceT $ connect uri >>= announce q | 28 | q <- arbitrarySample |
29 | validateInfo q info | 29 | info <- runResourceT $ announce mgr uri q |
30 | validateInfo q info | ||
30 | 31 | ||
31 | describe "scrape" $ do | 32 | describe "scrape" $ do |
32 | it "have valid response" $ do | 33 | it "have valid response" $ do |
33 | xs <- runResourceT $ connect uri >>= scrape [def] | 34 | withManager def $ \ mgr -> do |
34 | L.length xs `shouldSatisfy` (>= 1) | 35 | xs <- runResourceT $ scrape mgr uri [def] |
36 | L.length xs `shouldSatisfy` (>= 1) | ||
diff --git a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs index e46f15b6..f3dcec88 100644 --- a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs +++ b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | |||
@@ -24,10 +24,12 @@ spec = do | |||
24 | context (show uri) $ do | 24 | context (show uri) $ do |
25 | describe "announce" $ do | 25 | describe "announce" $ do |
26 | it "have valid response" $ do | 26 | it "have valid response" $ do |
27 | q <- arbitrarySample | 27 | withManager def $ \ mgr -> do |
28 | connect uri >>= announce q >>= validateInfo q | 28 | q <- arbitrarySample |
29 | announce mgr uri q >>= validateInfo q | ||
29 | 30 | ||
30 | describe "scrape" $ do | 31 | describe "scrape" $ do |
31 | it "have valid response" $ do | 32 | it "have valid response" $ do |
32 | xs <- connect uri >>= scrape [def] | 33 | withManager def $ \ mgr -> do |
33 | L.length xs `shouldSatisfy` (>= 1) | 34 | xs <- scrape mgr uri [def] |
35 | L.length xs `shouldSatisfy` (>= 1) | ||
diff --git a/tests/Network/BitTorrent/Tracker/RPCSpec.hs b/tests/Network/BitTorrent/Tracker/RPCSpec.hs index 6bc72e86..340754d3 100644 --- a/tests/Network/BitTorrent/Tracker/RPCSpec.hs +++ b/tests/Network/BitTorrent/Tracker/RPCSpec.hs | |||
@@ -1,9 +1,11 @@ | |||
1 | module Network.BitTorrent.Tracker.RPCSpec (spec) where | 1 | module Network.BitTorrent.Tracker.RPCSpec (spec) where |
2 | import Control.Applicative | ||
2 | import Control.Monad | 3 | import Control.Monad |
3 | import Data.Default | 4 | import Data.Default |
4 | import Data.List as L | 5 | import Data.List as L |
5 | import Network.URI | 6 | import Network.URI |
6 | import Test.Hspec | 7 | import Test.Hspec |
8 | import Test.QuickCheck | ||
7 | 9 | ||
8 | import Network.BitTorrent.Tracker.MessageSpec hiding (spec) | 10 | import Network.BitTorrent.Tracker.MessageSpec hiding (spec) |
9 | import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec) | 11 | import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec) |
@@ -13,17 +15,26 @@ import Network.BitTorrent.Tracker.RPC as RPC | |||
13 | uris :: [URI] | 15 | uris :: [URI] |
14 | uris = UDP.trackerURIs ++ HTTP.trackerURIs | 16 | uris = UDP.trackerURIs ++ HTTP.trackerURIs |
15 | 17 | ||
18 | pinfo :: PeerInfo | ||
19 | pinfo = PeerInfo "-HS0003-203534.37422" 6000 Nothing | ||
20 | |||
21 | instance Arbitrary SAnnounceQuery where | ||
22 | arbitrary = SAnnounceQuery <$> arbitrary <*> arbitrary | ||
23 | <*> arbitrary <*> arbitrary | ||
24 | |||
16 | spec :: Spec | 25 | spec :: Spec |
17 | spec = do | 26 | spec = do |
18 | forM_ uris $ \ uri -> | 27 | forM_ uris $ \ uri -> |
19 | context (show uri) $ do | 28 | context (show uri) $ do |
20 | describe "announce" $ do | 29 | describe "announce" $ do |
21 | it "have valid response" $ do | 30 | it "have valid response" $ do |
22 | q <- arbitrarySample | 31 | withManager def pinfo $ \ mgr -> do |
23 | info <- connect uri >>= announce q | 32 | q <- arbitrarySample |
24 | validateInfo q info | 33 | info <- announce mgr uri q |
34 | return () | ||
25 | 35 | ||
26 | describe "scrape" $ do | 36 | describe "scrape" $ do |
27 | it "have valid response" $ do | 37 | it "have valid response" $ do |
28 | xs <- connect uri >>= scrape [def] | 38 | withManager def pinfo $ \ mgr -> do |
29 | L.length xs `shouldSatisfy` (>= 1) | 39 | xs <- scrape mgr uri [def] |
40 | L.length xs `shouldSatisfy` (>= 1) | ||
diff --git a/tests/Readme.md b/tests/Readme.md new file mode 100644 index 00000000..78981922 --- /dev/null +++ b/tests/Readme.md | |||
@@ -0,0 +1 @@ | |||
a | |||