hakyll/tests/Hakyll/Core/Runtime/Tests.hs

51 lines
1.7 KiB
Haskell
Raw Normal View History

2012-11-21 19:38:13 +00:00
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Hakyll.Core.Runtime.Tests
( tests
) where
--------------------------------------------------------------------------------
2012-11-24 09:56:19 +00:00
import System.FilePath ((</>))
import Test.Framework (Test, testGroup)
import Test.HUnit (Assertion, (@?=))
2012-11-21 19:38:13 +00:00
--------------------------------------------------------------------------------
2012-11-24 09:56:19 +00:00
import Hakyll
2012-12-31 14:16:14 +00:00
import qualified Hakyll.Core.Logger as Logger
2012-11-21 19:38:13 +00:00
import Hakyll.Core.Runtime
import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.Runtime.Tests" $ fromAssertions "run" [case01]
--------------------------------------------------------------------------------
case01 :: Assertion
2013-01-06 17:33:00 +00:00
case01 = do
_ <- run testConfiguration Logger.Error $ do
2012-11-21 19:38:13 +00:00
match "*.md" $ do
route $ setExtension "html"
2012-11-24 09:56:19 +00:00
compile $ do
2012-12-30 08:50:02 +00:00
getResourceBody
>>= saveSnapshot "raw"
>>= return . renderPandoc
2012-11-21 19:38:13 +00:00
2013-01-06 08:51:09 +00:00
create ["bodies.txt"] $ do
2012-11-24 12:34:50 +00:00
route idRoute
compile $ do
items <- loadAllSnapshots "*.md" "raw"
2012-11-24 12:34:50 +00:00
makeItem $ concat $ map itemBody (items :: [Item String])
2012-11-24 09:56:19 +00:00
2013-01-06 17:33:00 +00:00
example <- readFile $
destinationDirectory testConfiguration </> "example.html"
2012-11-24 09:56:19 +00:00
lines example @?= ["<p>This is an example.</p>"]
2013-01-06 17:33:00 +00:00
bodies <- readFile $ destinationDirectory testConfiguration </> "bodies.txt"
2012-11-24 09:56:19 +00:00
head (lines bodies) @?= "This is an example."
2013-01-06 17:33:00 +00:00
cleanTestEnv