]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/MetainfoTests.hs
metainfotest: add a piecelength test
[functorrent.git] / test / MetainfoTests.hs
index 86ecf482e16c7079886896b631d90d9a29dfe503..f27486f7efa6ce5b86c6d779c56aa229be365d06 100644 (file)
@@ -11,7 +11,20 @@ import Data.ByteString (readFile)
 tests :: IO ()
 tests = hspec $ do
   describe "read and interpret a torrent file 1" $ do
-    it "valid announceList" $ do
+    it "valid torrent file" $ do
       fc <- readFile "data/debian-7.8.0-amd64-CD-1.iso.torrent"
       (torrentToMetainfo fc) `shouldNotBe` (Left "parse error")
+    it "valid announce list" $ do
+      fc <- readFile "data/debian-7.8.0-amd64-CD-1.iso.torrent"
+      case torrentToMetainfo fc of
+        Left _ -> pending
+        Right metainfo -> do
+          announceList metainfo `shouldSatisfy` (not . null)
+    it "valid piece length" $ do
+      fc <- readFile "data/debian-7.8.0-amd64-CD-1.iso.torrent"
+      case torrentToMetainfo fc of
+        Left _ -> pending
+        Right metainfo -> do
+          let (Just info') = info metainfo
+          pieceLength info' `shouldBe` (524288 :: Integer)