From 6025e2fab8eae692b6af8ad8f2a6e3f27ebeafc4 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 24 May 2011 22:29:47 +0200 Subject: Finish rules test --- tests/Hakyll/Core/Rules/Tests.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/Hakyll/Core/Rules') diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs index 42b95fc..1b388e8 100644 --- a/tests/Hakyll/Core/Rules/Tests.hs +++ b/tests/Hakyll/Core/Rules/Tests.hs @@ -4,10 +4,14 @@ module Hakyll.Core.Rules.Tests where import qualified Data.Map as M +import qualified Data.Set as S import Test.Framework +import Test.Framework.Providers.HUnit +import Test.HUnit hiding (Test) import Hakyll.Core.Rules +import Hakyll.Core.Rules.Internal import Hakyll.Core.Identifier import Hakyll.Core.Routes import Hakyll.Core.Compiler @@ -15,6 +19,26 @@ import Hakyll.Core.Resource.Provider import Hakyll.Core.Resource.Provider.Dummy import Hakyll.Web.Page +tests :: [Test] +tests = + [ testCase "runRules" rulesTest + ] + +-- | Main test +-- +rulesTest :: Assertion +rulesTest = do + p <- provider + let ruleSet = runRules rules p + assert $ expected == S.fromList (map fst (rulesCompilers ruleSet)) + where + expected = S.fromList + [ Identifier Nothing "posts/a-post.markdown" + , Identifier Nothing "posts/some-other-post.markdown" + , Identifier (Just "raw") "posts/a-post.markdown" + , Identifier (Just "raw") "posts/some-other-post.markdown" + ] + -- | Dummy resource provider -- provider :: IO ResourceProvider @@ -34,6 +58,7 @@ rules = do -- Compile them, raw group "raw" $ do + route idRoute match "posts/*" $ do route $ setExtension "html" compile getResourceString -- cgit v1.2.3