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.hs40
1 files changed, 0 insertions, 40 deletions
diff --git a/tests/Data/Torrent/InfoHashSpec.hs b/tests/Data/Torrent/InfoHashSpec.hs
deleted file mode 100644
index 06570ec9..00000000
--- a/tests/Data/Torrent/InfoHashSpec.hs
+++ /dev/null
@@ -1,40 +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
13import Data.Torrent.InfoHash as IH
14
15
16instance Arbitrary InfoHash where
17 arbitrary = do
18 bs <- BS.pack <$> vectorOf 20 arbitrary
19 pure $ either (const (error "arbitrary infohash")) id $ safeConvert bs
20
21type TestPair = (FilePath, String)
22
23-- TODO add a few more torrents here
24torrentList :: [TestPair]
25torrentList =
26 [ ( "res" </> "dapper-dvd-amd64.iso.torrent"
27 , "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf")
28 ]
29
30infohashSpec :: (FilePath, String) -> Spec
31infohashSpec (filepath, expectedHash) = do
32 it ("should match " ++ filepath) $ do
33 torrent <- fromFile filepath
34 let actualHash = show $ idInfoHash $ tInfoDict torrent
35 actualHash `shouldBe` expectedHash
36
37spec :: Spec
38spec = do
39 describe "info hash" $ do
40 mapM_ infohashSpec torrentList