summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Core
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/Core
parente477ea753b59657ba8d185986c646cc45c66fcec (diff)
downloadhakyll-bbc2631c76db01e85ac5c4e75b1babb6c5b05697.tar.gz
Add TmpFile utilities
Diffstat (limited to 'tests/Hakyll/Core')
-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
5 files changed, 19 insertions, 11 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