summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Core/Rules
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Hakyll/Core/Rules')
-rw-r--r--tests/Hakyll/Core/Rules/Tests.hs25
1 files changed, 25 insertions, 0 deletions
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