diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2015-01-06 13:57:13 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2015-01-06 13:57:13 +0100 |
commit | b7940aca564a88e4e05b8a3d8e582aab7aed1ef9 (patch) | |
tree | f1060aeaa5833e0465c6a5b6ad0d7815c285025c /tests/Hakyll/Core/Rules | |
parent | 27c39423692637a4818d7c19da028cdd92c307ba (diff) | |
download | hakyll-b7940aca564a88e4e05b8a3d8e582aab7aed1ef9.tar.gz |
Add a test for #300
Diffstat (limited to 'tests/Hakyll/Core/Rules')
-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 |