]> git.rkrishnan.org Git - functorrent.git/blobdiff - test/MetainfoTests.hs
tests: add license boilerplate
[functorrent.git] / test / MetainfoTests.hs
index 86ecf482e16c7079886896b631d90d9a29dfe503..86aa0ff14b5632dece355c52a2f72be23c666a2d 100644 (file)
@@ -1,5 +1,24 @@
 -- | Tests for Metainfo module
 
+{-
+ - Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
+ -
+ - This file is part of FuncTorrent.
+ -
+ - FuncTorrent is free software; you can redistribute it and/or modify
+ - it under the terms of the GNU General Public License as published by
+ - the Free Software Foundation; either version 3 of the License, or
+ - (at your option) any later version.
+ -
+ - FuncTorrent is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ - GNU General Public License for more details.
+ -
+ - You should have received a copy of the GNU General Public License
+ - along with FuncTorrent; if not,  see <http://www.gnu.org/licenses/>
+ -}
+
 module MetainfoTests where
 
 import Prelude hiding (readFile)
@@ -11,7 +30,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)