summaryrefslogtreecommitdiff
path: root/tests/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-01-06 18:33:00 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-01-06 18:33:00 +0100
commitbbc2631c76db01e85ac5c4e75b1babb6c5b05697 (patch)
tree331dda3a0f45efee866db2a03fb5aa2858e826a8 /tests/Hakyll
parente477ea753b59657ba8d185986c646cc45c66fcec (diff)
downloadhakyll-bbc2631c76db01e85ac5c4e75b1babb6c5b05697.tar.gz
Add TmpFile utilities
Diffstat (limited to 'tests/Hakyll')
-rw-r--r--tests/Hakyll/Core/Provider/Tests.hs3
-rw-r--r--tests/Hakyll/Core/Rules/Tests.hs5
-rw-r--r--tests/Hakyll/Core/Runtime/Tests.hs11
-rw-r--r--tests/Hakyll/Core/Store/Tests.hs7
-rw-r--r--tests/Hakyll/Core/UnixFilter/Tests.hs4
-rw-r--r--tests/Hakyll/Web/Template/Context/Tests.hs5
-rw-r--r--tests/Hakyll/Web/Template/Tests.hs6
7 files changed, 27 insertions, 14 deletions
diff --git a/tests/Hakyll/Core/Provider/Tests.hs b/tests/Hakyll/Core/Provider/Tests.hs
index e1f9083..5fd9c0d 100644
--- a/tests/Hakyll/Core/Provider/Tests.hs
+++ b/tests/Hakyll/Core/Provider/Tests.hs
@@ -26,7 +26,8 @@ tests = testGroup "Hakyll.Core.Provider.Tests"
--------------------------------------------------------------------------------
case01 :: Assertion
-case01 = withTestStore $ \store -> do
+case01 = do
+ store <- newTestStore
provider <- newTestProvider store
assert $ resourceExists provider "example.md"
diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs
index d6fec31..631e082 100644
--- a/tests/Hakyll/Core/Rules/Tests.hs
+++ b/tests/Hakyll/Core/Rules/Tests.hs
@@ -14,12 +14,12 @@ import Test.HUnit (Assertion, assert, (@=?))
--------------------------------------------------------------------------------
import Hakyll.Core.Compiler
+import Hakyll.Core.File
import Hakyll.Core.Identifier
import Hakyll.Core.Identifier.Pattern
import Hakyll.Core.Routes
import Hakyll.Core.Rules
import Hakyll.Core.Rules.Internal
-import Hakyll.Core.Writable.CopyFile
import Hakyll.Web.Pandoc
import TestSuite.Util
@@ -33,7 +33,8 @@ tests = testGroup "Hakyll.Core.Rules.Tests"
--------------------------------------------------------------------------------
rulesTest :: Assertion
-rulesTest = withTestStore $ \store -> do
+rulesTest = do
+ store <- newTestStore
provider <- newTestProvider store
ruleSet <- runRules rules provider
let identifiers = S.fromList $ map fst $ rulesCompilers ruleSet
diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs
index 4b41bf5..c68d99e 100644
--- a/tests/Hakyll/Core/Runtime/Tests.hs
+++ b/tests/Hakyll/Core/Runtime/Tests.hs
@@ -25,8 +25,8 @@ tests = testGroup "Hakyll.Core.Runtime.Tests" $ fromAssertions "run" [case01]
--------------------------------------------------------------------------------
case01 :: Assertion
-case01 = withTestConfiguration $ \config -> do
- _ <- run config Logger.Error $ do
+case01 = do
+ _ <- run testConfiguration Logger.Error $ do
match "*.md" $ do
route $ setExtension "html"
compile $ do
@@ -40,8 +40,11 @@ case01 = withTestConfiguration $ \config -> do
items <- loadAllSnapshots "*.md" "raw"
makeItem $ concat $ map itemBody (items :: [Item String])
- example <- readFile $ destinationDirectory config </> "example.html"
+ example <- readFile $
+ destinationDirectory testConfiguration </> "example.html"
lines example @?= ["<p>This is an example.</p>"]
- bodies <- readFile $ destinationDirectory config </> "bodies.txt"
+ bodies <- readFile $ destinationDirectory testConfiguration </> "bodies.txt"
head (lines bodies) @?= "This is an example."
+
+ cleanTestEnv
diff --git a/tests/Hakyll/Core/Store/Tests.hs b/tests/Hakyll/Core/Store/Tests.hs
index 11a1a63..19b268b 100644
--- a/tests/Hakyll/Core/Store/Tests.hs
+++ b/tests/Hakyll/Core/Store/Tests.hs
@@ -38,7 +38,7 @@ simpleSetGet = Q.monadicIO $ do
Q.run $ Store.set store key (value :: String)
value' <- Q.run $ Store.get store key
Q.assert $ Store.Found value == value'
- Q.run cleanTestStore
+ Q.run cleanTestEnv
--------------------------------------------------------------------------------
@@ -52,12 +52,13 @@ persistentSetGet = Q.monadicIO $ do
store2 <- Q.run newTestStore
value' <- Q.run $ Store.get store2 key
Q.assert $ Store.Found value == value'
- Q.run cleanTestStore
+ Q.run cleanTestEnv
--------------------------------------------------------------------------------
wrongType :: H.Assertion
-wrongType = withTestStore $ \store -> do
+wrongType = do
+ store <- newTestStore
-- 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)
diff --git a/tests/Hakyll/Core/UnixFilter/Tests.hs b/tests/Hakyll/Core/UnixFilter/Tests.hs
index c3e1c99..350c857 100644
--- a/tests/Hakyll/Core/UnixFilter/Tests.hs
+++ b/tests/Hakyll/Core/UnixFilter/Tests.hs
@@ -27,11 +27,13 @@ tests = testGroup "Hakyll.Core.UnixFilter.Tests"
--------------------------------------------------------------------------------
unixFilterRev :: H.Assertion
-unixFilterRev = withTestStore $ \store -> do
+unixFilterRev = do
+ store <- newTestStore
provider <- newTestProvider store
output <- testCompilerDone store provider "russian.md" compiler
expected <- testCompilerDone store provider "russian.md" getResourceString
H.assert $ rev (itemBody expected) == lines (itemBody output)
+ cleanTestEnv
where
compiler = getResourceString >>= withItemBody (unixFilter "rev" [])
rev = map reverse . lines
diff --git a/tests/Hakyll/Web/Template/Context/Tests.hs b/tests/Hakyll/Web/Template/Context/Tests.hs
index f2fb42a..5533c71 100644
--- a/tests/Hakyll/Web/Template/Context/Tests.hs
+++ b/tests/Hakyll/Web/Template/Context/Tests.hs
@@ -29,7 +29,8 @@ tests = testGroup "Hakyll.Core.Template.Context.Tests"
--------------------------------------------------------------------------------
testDateField :: Assertion
-testDateField = withTestStore $ \store -> do
+testDateField = do
+ store <- newTestStore
provider <- newTestProvider store
date1 <- testContextDone store provider "example.md" "date" $
@@ -41,6 +42,8 @@ testDateField = withTestStore $ \store -> do
dateField "date" "%B %e, %Y"
date2 @=? "August 26, 2010"
+ cleanTestEnv
+
--------------------------------------------------------------------------------
testContextDone :: Store -> Provider -> Identifier -> String
diff --git a/tests/Hakyll/Web/Template/Tests.hs b/tests/Hakyll/Web/Template/Tests.hs
index 6c5c77a..fce5503 100644
--- a/tests/Hakyll/Web/Template/Tests.hs
+++ b/tests/Hakyll/Web/Template/Tests.hs
@@ -30,11 +30,13 @@ tests = testGroup "Hakyll.Core.Template.Tests"
--------------------------------------------------------------------------------
case01 :: Assertion
-case01 = withTestStore $ \store -> do
+case01 = do
+ store <- newTestStore
provider <- newTestProvider store
out <- resourceString provider "template.html.out"
- tpl <- testCompilerDone store provider "template.html" $ templateCompiler
+ tpl <- testCompilerDone store provider "template.html" $
+ templateCompiler
item <- testCompilerDone store provider "example.md" $
pandocCompiler >>= applyTemplate (itemBody tpl) testContext