From: Ramakrishnan Muthukrishnan Date: Wed, 19 Jul 2017 02:45:22 +0000 (+0530) Subject: re-arrange tests: add magnet uri tests X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/bcase/install.html?a=commitdiff_plain;h=80db01395c5440ca6bdeb3160070f6213c5e52e7;p=functorrent.git re-arrange tests: add magnet uri tests --- diff --git a/test/MagneturiTests.hs b/test/MagneturiTests.hs new file mode 100644 index 0000000..3689ea4 --- /dev/null +++ b/test/MagneturiTests.hs @@ -0,0 +1,37 @@ +{- +Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan + +This file is part of FuncTorrent. + +FuncTorrent is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +FuncTorrent is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with FuncTorrent; if not, see +-} + +-- | Tests for MagnetURI module +{-# LANGUAGE OverloadedStrings #-} + +module MagneturiTests (tests) where + +import FuncTorrent.MagnetURI +import Test.Hspec + +tests :: IO () +tests = hspec $ do + describe "MagnetURI starts with magnet:? .. " $ do + it "Valid MagnetURI" $ do + parseMagneturi "magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a" + `shouldBe` (Right (Magnetinfo {infoHash = "urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a", trackerlist = [], name = "", xlen = Nothing})) + it "Valid MagnetURI with tracker list" $ do + 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" + `shouldBe` (Right (Magnetinfo {infoHash = "urn:btih:1f8a4ee3c3f57e81f8f0b4e658177201fc2a3118", trackerlist = [ "udp://tracker.leechers-paradise.org", "udp://zer0day.ch/", "udp://open.demonii.com/", "udp://tracker.coppersurfer.tk/", "udp://exodus.desync.com/"], name = "Honey+Bee+2+%5B2017%5D+Malayalam+DVDRiP+x264+AAC+700MB+ZippyMovieZ+E", xlen = Nothing})) + diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..09d3e98 --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,9 @@ +-- | Tests main + +module Main where + +import MagneturiTests + +main :: IO () +main = tests +