diff options
-rw-r--r-- | tests/Hakyll/Core/Rules/Tests.hs | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs index 12258f9..dbd077d 100644 --- a/tests/Hakyll/Core/Rules/Tests.hs +++ b/tests/Hakyll/Core/Rules/Tests.hs @@ -8,7 +8,9 @@ module Hakyll.Core.Rules.Tests -------------------------------------------------------------------------------- import Data.IORef (IORef, newIORef, readIORef, writeIORef) +import qualified Data.Map as M import qualified Data.Set as S +import System.FilePath ((</>)) import Test.Framework (Test, testGroup) import Test.HUnit (Assertion, assert, (@=?)) @@ -44,22 +46,29 @@ case01 = do runRoutes routes provider i >>= \(r, _) -> Just ex @=? r -- Test that we have some identifiers and that the routes work out - assert $ all (`S.member` identifiers) expected - checkRoute "example.html" "example.md" - checkRoute "example.md" (sv "raw" "example.md") - checkRoute "example.md" (sv "nav" "example.md") - checkRoute "example.mv1" (sv "mv1" "example.md") - checkRoute "example.mv2" (sv "mv2" "example.md") + S.fromList expected @=? identifiers + checkRoute "example.html" "example.md" + checkRoute "example.md" (sv "raw" "example.md") + checkRoute "example.md" (sv "nav" "example.md") + checkRoute "example.mv1" (sv "mv1" "example.md") + checkRoute "example.mv2" (sv "mv2" "example.md") + checkRoute "food/example.md" (sv "metadataMatch" "example.md") readIORef ioref >>= assert cleanTestEnv where sv g = setVersion (Just g) expected = - [ "example.md" - , "russian.md" - , sv "raw" "example.md" + [ "example.md" + , sv "raw" "example.md" + , sv "metadataMatch" "example.md" + , sv "nav" "example.md" + , sv "mv1" "example.md" + , sv "mv2" "example.md" + + , "russian.md" , sv "raw" "russian.md" - , sv "nav" "example.md" + , sv "mv1" "russian.md" + , sv "mv2" "russian.md" ] @@ -79,6 +88,11 @@ rules01 ioref = do route idRoute compile getResourceString + version "metadataMatch" $ + matchMetadata "*.md" (\md -> M.lookup "subblog" md == Just "food") $ do + route $ customRoute $ \id' -> "food" </> toFilePath id' + compile getResourceString + -- Regression test version "nav" $ match (fromList ["example.md"]) $ do route idRoute |