summaryrefslogtreecommitdiff
path: root/tests/Data/Torrent/InfoHashSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Data/Torrent/InfoHashSpec.hs')
-rw-r--r--tests/Data/Torrent/InfoHashSpec.hs38
1 files changed, 0 insertions, 38 deletions
diff --git a/tests/Data/Torrent/InfoHashSpec.hs b/tests/Data/Torrent/InfoHashSpec.hs
deleted file mode 100644
index 9accc741..00000000
--- a/tests/Data/Torrent/InfoHashSpec.hs
+++ /dev/null
@@ -1,38 +0,0 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Data.Torrent.InfoHashSpec (spec) where
3
4import Control.Applicative
5import Data.ByteString as BS
6import Data.Convertible
7import System.FilePath
8import Test.Hspec
9import Test.QuickCheck
10import Test.QuickCheck.Instances ()
11
12import Data.Torrent
13
14instance Arbitrary InfoHash where
15 arbitrary = do
16 bs <- BS.pack <$> vectorOf 20 arbitrary
17 pure $ either (const (error "arbitrary infohash")) id $ safeConvert bs
18
19type TestPair = (FilePath, String)
20
21-- TODO add a few more torrents here
22torrentList :: [TestPair]
23torrentList =
24 [ ( "res" </> "dapper-dvd-amd64.iso.torrent"
25 , "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf")
26 ]
27
28infohashSpec :: (FilePath, String) -> Spec
29infohashSpec (filepath, expectedHash) = do
30 it ("should match " ++ filepath) $ do
31 torrent <- fromFile filepath
32 let actualHash = show $ idInfoHash $ tInfoDict torrent
33 actualHash `shouldBe` expectedHash
34
35spec :: Spec
36spec = do
37 describe "info hash" $ do
38 mapM_ infohashSpec torrentList