on master help sign in
Add a test for #300
commitb7940aca564a88e4e05b8a3d8e582aab7aed1ef9 authorJasper Van der Jeugt <m@jaspervdj.be> dateTue 6 Jan 2015, 13:57 (12 years ago) parent27c3942
1 file changed+24−10
tests/Hakyll/Core/Rules/Tests.hs+24−10
tests/Hakyll/Core/Rules/Tests.hs+24−10
@@ -8,7 +8,9 @@ module Hakyll.Core.Rules.Tests
88--------------------------------------------------------------------------------
99import Data.IORef (IORef, newIORef, readIORef,
1010 writeIORef)
11+import qualified Data.Map as M
1112import qualified Data.Set as S
13+import System.FilePath ((</>))
1214import Test.Framework (Test, testGroup)
1315import Test.HUnit (Assertion, assert, (@=?))
1416
@@ -44,22 +46,29 @@ case01 = do
4446 runRoutes routes provider i >>= \(r, _) -> Just ex @=? r
4547
4648 -- Test that we have some identifiers and that the routes work out
47− assert $ all (`S.member` identifiers) expected
48− checkRoute "example.html" "example.md"
49− checkRoute "example.md" (sv "raw" "example.md")
50− checkRoute "example.md" (sv "nav" "example.md")
51− checkRoute "example.mv1" (sv "mv1" "example.md")
52− checkRoute "example.mv2" (sv "mv2" "example.md")
49+ S.fromList expected @=? identifiers
50+ checkRoute "example.html" "example.md"
51+ checkRoute "example.md" (sv "raw" "example.md")
52+ checkRoute "example.md" (sv "nav" "example.md")
53+ checkRoute "example.mv1" (sv "mv1" "example.md")
54+ checkRoute "example.mv2" (sv "mv2" "example.md")
55+ checkRoute "food/example.md" (sv "metadataMatch" "example.md")
5356 readIORef ioref >>= assert
5457 cleanTestEnv
5558 where
5659 sv g = setVersion (Just g)
5760 expected =
58− [ "example.md"
59− , "russian.md"
60− , sv "raw" "example.md"
61+ [ "example.md"
62+ , sv "raw" "example.md"
63+ , sv "metadataMatch" "example.md"
64+ , sv "nav" "example.md"
65+ , sv "mv1" "example.md"
66+ , sv "mv2" "example.md"
67+
68+ , "russian.md"
6169 , sv "raw" "russian.md"
62− , sv "nav" "example.md"
70+ , sv "mv1" "russian.md"
71+ , sv "mv2" "russian.md"
6372 ]
6473
6574
@@ -79,6 +88,11 @@ rules01 ioref = do
7988 route idRoute
8089 compile getResourceString
8190
91+ version "metadataMatch" $
92+ matchMetadata "*.md" (\md -> M.lookup "subblog" md == Just "food") $ do
93+ route $ customRoute $ \id' -> "food" </> toFilePath id'
94+ compile getResourceString
95+
8296 -- Regression test
8397 version "nav" $ match (fromList ["example.md"]) $ do
8498 route idRoute