summaryrefslogtreecommitdiff
path: root/tests/Data/Torrent/InfoHashSpec.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-10-31 11:25:59 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-10-31 11:25:59 +0400
commit01cef3fafc27d39d88c94cacdcd8e204c5f66b86 (patch)
tree01040aca19e49f4e7937383fef53b8c82bcec12b /tests/Data/Torrent/InfoHashSpec.hs
parentc1fec260f47084300ac30de2e43d52966316a2c7 (diff)
Merge bittorrent package with torrent-content
Diffstat (limited to 'tests/Data/Torrent/InfoHashSpec.hs')
-rw-r--r--tests/Data/Torrent/InfoHashSpec.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Data/Torrent/InfoHashSpec.hs b/tests/Data/Torrent/InfoHashSpec.hs
new file mode 100644
index 00000000..ba9ce9a4
--- /dev/null
+++ b/tests/Data/Torrent/InfoHashSpec.hs
@@ -0,0 +1,36 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Data.Torrent.InfoHashSpec (spec) where
3
4import Control.Applicative
5import System.FilePath
6import Test.Hspec
7import Test.QuickCheck
8import Test.QuickCheck.Instances ()
9
10import Data.Torrent
11import Data.Torrent.InfoHash as IH
12
13
14instance Arbitrary InfoHash where
15 arbitrary = IH.hash <$> arbitrary
16
17type TestPair = (FilePath, String)
18
19-- TODO add a few more torrents here
20torrentList :: [TestPair]
21torrentList =
22 [ ( "res" </> "dapper-dvd-amd64.iso.torrent"
23 , "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf")
24 ]
25
26infohashSpec :: (FilePath, String) -> Spec
27infohashSpec (filepath, expectedHash) = do
28 it ("should match " ++ filepath) $ do
29 torrent <- fromFile filepath
30 let actualHash = show $ idInfoHash $ tInfoDict torrent
31 actualHash `shouldBe` expectedHash
32
33spec :: Spec
34spec = do
35 describe "info hash" $ do
36 mapM_ infohashSpec torrentList