]> git.rkrishnan.org Git - functorrent.git/blob - test/MagneturiTests.hs
Basic infrastructure for Extension messages (BEP 0010)
[functorrent.git] / test / MagneturiTests.hs
1 {-
2 Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
3
4 This file is part of FuncTorrent.
5
6 FuncTorrent is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 FuncTorrent is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with FuncTorrent; if not,  see <http://www.gnu.org/licenses/>
18 -}
19
20 -- | Tests for MagnetURI module
21 {-# LANGUAGE OverloadedStrings #-}
22
23 module MagneturiTests (tests) where
24
25 import FuncTorrent.MagnetURI
26 import Test.Hspec
27
28 tests :: IO ()
29 tests = hspec $ do
30   describe "MagnetURI starts with magnet:? .. " $ do
31     it "Valid MagnetURI" $ do
32       parseMagneturi "magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a"
33       `shouldBe` (Right (Magnetinfo {infoHash = "urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a", trackerlist = [], name = "", xlen = Nothing}))
34     it "Valid MagnetURI with tracker list" $ do
35       parseMagneturi "magnet:?xt=urn:btih:1f8a4ee3c3f57e81f8f0b4e658177201fc2a3118&dn=Honey+Bee+2+%5B2017%5D+Malayalam+DVDRiP+x264+AAC+700MB+ZippyMovieZ+E&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969"
36       `shouldBe` (Right (Magnetinfo {infoHash = "urn:btih:1f8a4ee3c3f57e81f8f0b4e658177201fc2a3118", trackerlist = [ "udp://tracker.leechers-paradise.org:6969", "udp://zer0day.ch:1337", "udp://open.demonii.com:1337", "udp://tracker.coppersurfer.tk:6969", "udp://exodus.desync.com:6969"], name = "Honey+Bee+2+[2017]+Malayalam+DVDRiP+x264+AAC+700MB+ZippyMovieZ+E", xlen = Nothing}))
37
38     it "Valid MagnetURI with tracker list 2" $ do
39       parseMagneturi "magnet:?xt=urn:btih:88c491dbbcdb0bb1ad142fabddd1436c09f17e7e&dn=CIA+Comrade+in+America+%282017%29+Malayalam+DESI+SCR+x264+AAC+700MB+&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969"
40       `shouldBe` (Right (Magnetinfo {infoHash = "urn:btih:88c491dbbcdb0bb1ad142fabddd1436c09f17e7e", trackerlist = ["udp://tracker.leechers-paradise.org:6969","udp://zer0day.ch:1337","udp://open.demonii.com:1337","udp://tracker.coppersurfer.tk:6969","udp://exodus.desync.com:6969"], name = "CIA+Comrade+in+America+(2017)+Malayalam+DESI+SCR+x264+AAC+700MB+", xlen = Nothing }))