summaryrefslogtreecommitdiff
path: root/tests/Page.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-23 14:32:43 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-23 14:32:43 +0100
commiteabc26812d5deb6ef818c20b2ed4c4d07e14feaa (patch)
tree238503a400e26500eb9d7f7d5bef64db7902a7ba /tests/Page.hs
parentad6712121ffc3e41f6bd2a9833267252315b6f65 (diff)
downloadhakyll-eabc26812d5deb6ef818c20b2ed4c4d07e14feaa.tar.gz
Remove old tests for now
Diffstat (limited to 'tests/Page.hs')
-rw-r--r--tests/Page.hs92
1 files changed, 0 insertions, 92 deletions
diff --git a/tests/Page.hs b/tests/Page.hs
deleted file mode 100644
index be49ad0..0000000
--- a/tests/Page.hs
+++ /dev/null
@@ -1,92 +0,0 @@
-module Page
- ( pageGroup
- ) where
-
-import qualified Data.Map as M
-
-import Control.Monad.Reader (runReaderT)
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-import System.Directory (getTemporaryDirectory, removeFile)
-import System.FilePath ((</>))
-
-import Text.Hakyll.Page
-import Text.Hakyll.Pandoc
-import Text.Hakyll.Context
-import Text.Hakyll.HakyllAction
-import Text.Hakyll
-
--- Page test group.
-pageGroup = testGroup "Page"
- [ testCase "test_readPage_1" test_readPage_1
- , testCase "test_readPage_2" test_readPage_2
- , testCase "test_readPage_3" test_readPage_3
- , testCase "test_readPage_4" test_readPage_4
- ]
-
--- | An abstract function to test page reading.
-test_readPage :: FilePath -- ^ Filename to give to the temporary file.
- -> String -- ^ Content to put in the file.
- -> (Context -> Bool) -- ^ Assertion to run on the result Context.
- -> IO Bool -- ^ Result of the assertion.
-test_readPage fileName content assertion = do
- temporaryDir <- getTemporaryDirectory
- let temporaryFile = temporaryDir </> fileName
- writeFile temporaryFile content
- page <- runDefaultHakyll (runHakyllAction $ createPage temporaryFile)
- removeFile temporaryFile
- return $ assertion page
-
--- | readPage test case 1.
-test_readPage_1 = test_readPage fileName content assertion @? "test_readPage_1"
- where
- fileName = "test_readPage_1.markdown"
- content = unlines [ "---"
- , "author: Eric Cartman"
- , "---"
- , "This is a simple test."
- ]
- assertion page = M.lookup "author" (unContext page) == Just "Eric Cartman"
-
--- | readPage test case 2.
-test_readPage_2 = test_readPage fileName content assertion @? "test_readPage_2"
- where
- fileName = "test_readPage_2.txt"
- content = unlines [ "--- someSection"
- , "This is a section."
- , "---"
- , "This is the body."
- ]
- assertion page =
- let m = unContext page
- in M.lookup "someSection" m == Just "This is a section.\n"
- && M.lookup "body" m == Just "This is the body.\n"
-
--- | readPage test case 3.
-test_readPage_3 = test_readPage fileName content assertion @? "test_readPage_3"
- where
- fileName = "test_readPage_3.txt"
- content = unlines [ "No metadata here, sorry."
- ]
- assertion page =
- M.lookup "body" (unContext page) == Just "No metadata here, sorry.\n"
-
--- | readPage test case 4.
-test_readPage_4 = test_readPage fileName content assertion @? "test_readPage_4"
- where
- fileName = "test_readPage_4.txt"
- content = unlines [ "--- section"
- , "This is a section."
- , "---"
- , "Header"
- , "------"
- , "The header is not a separate section."
- ]
- assertion page = M.lookup "body" (unContext page) == Just body
- body = unlines [ "Header"
- , "------"
- , "The header is not a separate section."
- ]