diff options
Diffstat (limited to 'tests/Data/Torrent/InfoHashSpec.hs')
-rw-r--r-- | tests/Data/Torrent/InfoHashSpec.hs | 38 |
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 #-} | ||
2 | module Data.Torrent.InfoHashSpec (spec) where | ||
3 | |||
4 | import Control.Applicative | ||
5 | import Data.ByteString as BS | ||
6 | import Data.Convertible | ||
7 | import System.FilePath | ||
8 | import Test.Hspec | ||
9 | import Test.QuickCheck | ||
10 | import Test.QuickCheck.Instances () | ||
11 | |||
12 | import Data.Torrent | ||
13 | |||
14 | instance Arbitrary InfoHash where | ||
15 | arbitrary = do | ||
16 | bs <- BS.pack <$> vectorOf 20 arbitrary | ||
17 | pure $ either (const (error "arbitrary infohash")) id $ safeConvert bs | ||
18 | |||
19 | type TestPair = (FilePath, String) | ||
20 | |||
21 | -- TODO add a few more torrents here | ||
22 | torrentList :: [TestPair] | ||
23 | torrentList = | ||
24 | [ ( "res" </> "dapper-dvd-amd64.iso.torrent" | ||
25 | , "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf") | ||
26 | ] | ||
27 | |||
28 | infohashSpec :: (FilePath, String) -> Spec | ||
29 | infohashSpec (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 | |||
35 | spec :: Spec | ||
36 | spec = do | ||
37 | describe "info hash" $ do | ||
38 | mapM_ infohashSpec torrentList | ||