on master help sign in
Add a test for metadataRoute
commit55a389ee7c9a33337679d24c669c4556cbd77cab authorJasper Van der Jeugt <m@jaspervdj.be> dateFri 3 Jan 2014, 15:56 (13 years ago) parent6ba9099
2 files changed+11−2
tests/Hakyll/Core/Routes/Tests.hs+10−2 tests/data/example.md.metadata+1
tests/Hakyll/Core/Routes/Tests.hs+10−2
@@ -6,6 +6,8 @@ module Hakyll.Core.Routes.Tests
66
77
88--------------------------------------------------------------------------------
9+import qualified Data.Map as M
10+import System.FilePath ((</>))
911import Test.Framework (Test, testGroup)
1012import Test.HUnit (Assertion, (@=?))
1113
@@ -33,12 +35,18 @@ tests = testGroup "Hakyll.Core.Routes.Tests" $ fromAssertions "runRoutes"
3335 , testRoutes "tags/bar.xml"
3436 (gsubRoute "rss/" (const "") `composeRoutes` setExtension "xml")
3537 "tags/rss/bar"
38+
39+ , testRoutes "food/example.md" (metadataRoute $ \md -> customRoute $ \id' ->
40+ M.findWithDefault "?" "subblog" md </> toFilePath id')
41+ "example.md"
3642 ]
3743
3844
3945--------------------------------------------------------------------------------
4046testRoutes :: FilePath -> Routes -> Identifier -> Assertion
4147testRoutes expected r id' = do
42− (route, _) <- runRoutes r
43− (error "Hakyll.Core.Routes.Tests: no provider") id'
48+ store <- newTestStore
49+ provider <- newTestProvider store
50+ (route, _) <- runRoutes r provider id'
4451 Just expected @=? route
52+ cleanTestEnv
tests/data/example.md.metadata+1
@@ -1,2 +1,3 @@
11external: External data
22date: 2012-10-22 14:35:24
3+subblog: food