summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 13:01:57 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 13:01:57 +0100
commit4c40cea9e1ddef01e25f135656551ef8d494cffb (patch)
tree7c5f9d1983d9dfe0732c628a54d122f6b389679e /tests
parent61dcb5f454fcbd912b09839021f4c79ca60973fe (diff)
parent1c2804287a099b4ac2f6c2d9b3db452f7ef7bee1 (diff)
downloadhakyll-4c40cea9e1ddef01e25f135656551ef8d494cffb.tar.gz
Merge branch 'master' into dev-metadata-route
Conflicts: tests/Hakyll/Core/Rules/Tests.hs
Diffstat (limited to 'tests')
-rw-r--r--tests/Hakyll/Core/Rules/Tests.hs16
-rw-r--r--tests/Hakyll/Core/Runtime/Tests.hs22
-rw-r--r--tests/data/images/favicon.icobin0 -> 1150 bytes
3 files changed, 28 insertions, 10 deletions
diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs
index 908f712..6461b9d 100644
--- a/tests/Hakyll/Core/Rules/Tests.hs
+++ b/tests/Hakyll/Core/Rules/Tests.hs
@@ -10,7 +10,6 @@ import Data.IORef (IORef, newIORef, readIORef,
writeIORef)
import qualified Data.Set as S
import Test.Framework (Test, testGroup)
-import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, assert, (@=?))
@@ -28,18 +27,17 @@ import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
-tests = testGroup "Hakyll.Core.Rules.Tests"
- [ testCase "runRules" rulesTest
- ]
+tests = testGroup "Hakyll.Core.Rules.Tests" $ fromAssertions "runRules"
+ [case01]
--------------------------------------------------------------------------------
-rulesTest :: Assertion
-rulesTest = do
+case01 :: Assertion
+case01 = do
ioref <- newIORef False
store <- newTestStore
provider <- newTestProvider store
- ruleSet <- runRules (rules ioref) provider
+ ruleSet <- runRules (rules01 ioref) provider
let identifiers = S.fromList $ map fst $ rulesCompilers ruleSet
routes = rulesRoutes ruleSet
checkRoute ex i =
@@ -66,8 +64,8 @@ rulesTest = do
--------------------------------------------------------------------------------
-rules :: IORef Bool -> Rules ()
-rules ioref = do
+rules01 :: IORef Bool -> Rules ()
+rules01 ioref = do
-- Compile some posts
match "*.md" $ do
route $ setExtension "html"
diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs
index c68d99e..8a05824 100644
--- a/tests/Hakyll/Core/Runtime/Tests.hs
+++ b/tests/Hakyll/Core/Runtime/Tests.hs
@@ -20,7 +20,8 @@ import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
-tests = testGroup "Hakyll.Core.Runtime.Tests" $ fromAssertions "run" [case01]
+tests = testGroup "Hakyll.Core.Runtime.Tests" $
+ fromAssertions "run" [case01, case02]
--------------------------------------------------------------------------------
@@ -48,3 +49,22 @@ case01 = do
head (lines bodies) @?= "This is an example."
cleanTestEnv
+
+
+--------------------------------------------------------------------------------
+case02 :: Assertion
+case02 = do
+ _ <- run testConfiguration Logger.Error $ do
+ match "images/favicon.ico" $ do
+ route $ gsubRoute "images/" (const "")
+ compile $ makeItem ("Test" :: String)
+
+ match "images/**" $ do
+ route idRoute
+ compile copyFileCompiler
+
+ favicon <- readFile $
+ destinationDirectory testConfiguration </> "favicon.ico"
+ favicon @?= "Test"
+
+ cleanTestEnv
diff --git a/tests/data/images/favicon.ico b/tests/data/images/favicon.ico
new file mode 100644
index 0000000..fc2cca2
--- /dev/null
+++ b/tests/data/images/favicon.ico
Binary files differ