import Test.Hspec
-import FuncTorrent.Metainfo (Info(..), Metainfo(..), DynamicInfo(..), FileInfo(..), torrentToMetainfo)
+import FuncTorrent.Metainfo (Info(..), Metainfo(..), FileInfo(..), torrentToMetainfo)
import qualified Data.ByteString.Lazy.Char8 as BC (readFile, toStrict)
import qualified Data.ByteString as B
length (announceList m) `shouldBe` 1
pieceLength (info m) `shouldBe` 524288
pieces (info m) `shouldSatisfy` (\p -> B.length p `mod` 20 == 0)
- let (SingleFileInfo file') = dyninfo $ info m
- (FileInfo _ _ name') = file'
+ let fs = files $ info m
+ (FileInfo _ _ name') = head fs
name' `shouldNotBe` ""
+ length fs `shouldBe` 1
it "torrent-file-2" $ do
c <- BC.readFile "data/test2.torrent"
let (Right m) = torrentToMetainfo (BC.toStrict c)
- (SingleFileInfo file') = dyninfo $ info m
- (FileInfo _ _ name') = file'
+ fs = files $ info m
+ (FileInfo _ _ name') = head fs
name' `shouldNotBe` ""
+ length fs `shouldBe` 1
it "torrent-file-3" $ do
c <- BC.readFile "data/test3.torrent"
let (Right m) = torrentToMetainfo (BC.toStrict c)
- (SingleFileInfo file') = dyninfo $ info m
- (FileInfo _ _ name') = file'
+ fs = files $ info m
+ (FileInfo _ _ name') = head fs
name' `shouldNotBe` ""
+ length fs `shouldBe` 1
it "torrent-file-4" $ do
c <- BC.readFile "data/test4.torrent"
let (Right m) = torrentToMetainfo (BC.toStrict c)
length (announceList m) `shouldBe` 3
- let (MultiFileInfo dname' files') = dyninfo $ info m
- length files' `shouldBe` 9 -- 9 files in the torrent
- dname' `shouldBe` "NASA_NTRS_Archive_19740027163"
+ let fs = files $ info m
+ p = path $ head fs
+ length fs `shouldBe` 9 -- 9 files in the torrent
+ p `shouldStartWith` "NASA_NTRS_Archive_19740027163"
+