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

48 lines
1.6 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
case01 = withTestConfiguration $ \config -> do
2012-12-31 14:16:14 +00:00
_ <- run config 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
2012-11-24 12:34:50 +00:00
match "bodies.txt" $ do
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
example <- readFile $ destinationDirectory config </> "example.html"
lines example @?= ["<p>This is an example.</p>"]
bodies <- readFile $ destinationDirectory config </> "bodies.txt"
head (lines bodies) @?= "This is an example."