summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Hakyll/Core/Routes/Tests.hs12
-rw-r--r--tests/data/example.md.metadata1
2 files changed, 11 insertions, 2 deletions
diff --git a/tests/Hakyll/Core/Routes/Tests.hs b/tests/Hakyll/Core/Routes/Tests.hs
index c681c99..4f975ae 100644
--- a/tests/Hakyll/Core/Routes/Tests.hs
+++ b/tests/Hakyll/Core/Routes/Tests.hs
@@ -6,6 +6,8 @@ module Hakyll.Core.Routes.Tests
--------------------------------------------------------------------------------
+import qualified Data.Map as M
+import System.FilePath ((</>))
import Test.Framework (Test, testGroup)
import Test.HUnit (Assertion, (@=?))
@@ -33,12 +35,18 @@ tests = testGroup "Hakyll.Core.Routes.Tests" $ fromAssertions "runRoutes"
, testRoutes "tags/bar.xml"
(gsubRoute "rss/" (const "") `composeRoutes` setExtension "xml")
"tags/rss/bar"
+
+ , testRoutes "food/example.md" (metadataRoute $ \md -> customRoute $ \id' ->
+ M.findWithDefault "?" "subblog" md </> toFilePath id')
+ "example.md"
]
--------------------------------------------------------------------------------
testRoutes :: FilePath -> Routes -> Identifier -> Assertion
testRoutes expected r id' = do
- (route, _) <- runRoutes r
- (error "Hakyll.Core.Routes.Tests: no provider") id'
+ store <- newTestStore
+ provider <- newTestProvider store
+ (route, _) <- runRoutes r provider id'
Just expected @=? route
+ cleanTestEnv
diff --git a/tests/data/example.md.metadata b/tests/data/example.md.metadata
index 9685918..5d463ae 100644
--- a/tests/data/example.md.metadata
+++ b/tests/data/example.md.metadata
@@ -1,2 +1,3 @@
external: External data
date: 2012-10-22 14:35:24
+subblog: food