summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker/MessageSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent/Tracker/MessageSpec.hs')
-rw-r--r--tests/Network/BitTorrent/Tracker/MessageSpec.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/tests/Network/BitTorrent/Tracker/MessageSpec.hs b/tests/Network/BitTorrent/Tracker/MessageSpec.hs
index 8a06aaba..2a882c5d 100644
--- a/tests/Network/BitTorrent/Tracker/MessageSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/MessageSpec.hs
@@ -44,8 +44,8 @@ instance Arbitrary AnnounceQuery where
44baseURI :: URI 44baseURI :: URI
45baseURI = fromJust $ parseURI "http://a" 45baseURI = fromJust $ parseURI "http://a"
46 46
47parseUriQuery :: URI -> [(Text, Text)] 47parseUriQuery :: URI -> SimpleQuery
48parseUriQuery = filterMaybes . parseQueryText . BC.pack . uriQuery 48parseUriQuery = filterMaybes . parseQuery . BC.pack . uriQuery
49 where 49 where
50 filterMaybes :: [(a, Maybe b)] -> [(a, b)] 50 filterMaybes :: [(a, Maybe b)] -> [(a, b)]
51 filterMaybes = catMaybes . L.map f 51 filterMaybes = catMaybes . L.map f
@@ -53,16 +53,10 @@ parseUriQuery = filterMaybes . parseQueryText . BC.pack . uriQuery
53 f (a, Nothing) = Nothing 53 f (a, Nothing) = Nothing
54 f (a, Just b ) = Just (a, b) 54 f (a, Just b ) = Just (a, b)
55 55
56test = do
57 let q = unGen arbitrary (mkStdGen 0) 0
58 print $ renderAnnounceQuery baseURI q
59 print $ parseUriQuery $ renderAnnounceQuery baseURI q
60
61spec :: Spec 56spec :: Spec
62spec = do 57spec = do
63 describe "Announce" $ do 58 describe "Announce" $ do
64 before test $ 59 it "properly url encoded" $ property $ \ q ->
65 it "properly url encoded" $ property $ \ q ->
66 parseAnnounceQuery (parseUriQuery (renderAnnounceQuery baseURI q)) 60 parseAnnounceQuery (parseUriQuery (renderAnnounceQuery baseURI q))
67 `shouldBe` Right q 61 `shouldBe` Right q
68 62