From 0a6b2b259862b90ccca11281de89091e2e01cb4d Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 24 Nov 2012 10:56:19 +0100 Subject: Add snapshots --- tests/Hakyll/Core/Runtime/Tests.hs | 28 ++++++++++++++++++---------- tests/Hakyll/Core/Store/Tests.hs | 1 - 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs index bb39a5f..0d202c7 100644 --- a/tests/Hakyll/Core/Runtime/Tests.hs +++ b/tests/Hakyll/Core/Runtime/Tests.hs @@ -6,17 +6,14 @@ module Hakyll.Core.Runtime.Tests -------------------------------------------------------------------------------- -import System.FilePath (()) -import Test.Framework (Test, testGroup) -import Test.HUnit (Assertion, (@?=)) +import System.FilePath (()) +import Test.Framework (Test, testGroup) +import Test.HUnit (Assertion, (@?=)) -------------------------------------------------------------------------------- -import Hakyll.Core.Configuration -import Hakyll.Core.Routes -import Hakyll.Core.Rules +import Hakyll import Hakyll.Core.Runtime -import Hakyll.Web.Page import TestSuite.Util @@ -31,7 +28,18 @@ case01 = withTestConfiguration $ \config -> do _ <- run config $ do match "*.md" $ do route $ setExtension "html" - compile $ pageCompiler + compile $ do + body <- getResourceBody + saveSnapshot "raw" body + return $ renderPandoc body - out <- readFile $ destinationDirectory config "example.html" - lines out @?= ["

This is an example.

"] + match "bodies.txt" $ route idRoute + create "bodies.txt" $ do + items <- requireAllSnapshots "*.md" "raw" :: Compiler [Item String] + makeItem $ concat $ map itemBody items + + example <- readFile $ destinationDirectory config "example.html" + lines example @?= ["

This is an example.

"] + + bodies <- readFile $ destinationDirectory config "bodies.txt" + head (lines bodies) @?= "This is an example." diff --git a/tests/Hakyll/Core/Store/Tests.hs b/tests/Hakyll/Core/Store/Tests.hs index bd6cba2..11a1a63 100644 --- a/tests/Hakyll/Core/Store/Tests.hs +++ b/tests/Hakyll/Core/Store/Tests.hs @@ -61,7 +61,6 @@ wrongType = withTestStore $ \store -> do -- Store a string and try to fetch an int Store.set store ["foo", "bar"] ("qux" :: String) value <- Store.get store ["foo", "bar"] :: IO (Store.Result Int) - print value H.assert $ case value of Store.WrongType e t -> e == typeOf (undefined :: Int) && -- cgit v1.2.3