diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2014-01-03 15:56:27 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2014-01-03 15:56:27 +0100 |
commit | 55a389ee7c9a33337679d24c669c4556cbd77cab (patch) | |
tree | d8456c72ea9337e03641830f01bc955208da901f /tests | |
parent | 6ba9099225f6325560e5933df974fbc06faa3951 (diff) | |
download | hakyll-55a389ee7c9a33337679d24c669c4556cbd77cab.tar.gz |
Add a test for metadataRoute
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Hakyll/Core/Routes/Tests.hs | 12 | ||||
-rw-r--r-- | tests/data/example.md.metadata | 1 |
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 |