summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-05-24 22:29:47 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-05-24 22:29:47 +0200
commit6025e2fab8eae692b6af8ad8f2a6e3f27ebeafc4 (patch)
treec26db0be8b52f7b15e280630afdc1c5a7456d3af
parent1dff099486f5baaf7bebd74eb70247647ab342f0 (diff)
downloadhakyll-6025e2fab8eae692b6af8ad8f2a6e3f27ebeafc4.tar.gz
Finish rules test
-rw-r--r--tests/Hakyll/Core/Rules/Tests.hs25
-rw-r--r--tests/TestSuite.hs3
2 files changed, 28 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
diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs
index 4d2c95d..37a9803 100644
--- a/tests/TestSuite.hs
+++ b/tests/TestSuite.hs
@@ -5,6 +5,7 @@ import Test.Framework (defaultMain, testGroup)
import qualified Hakyll.Core.DependencyAnalyzer.Tests
import qualified Hakyll.Core.Identifier.Tests
import qualified Hakyll.Core.Routes.Tests
+import qualified Hakyll.Core.Rules.Tests
import qualified Hakyll.Web.Page.Tests
import qualified Hakyll.Web.Page.Metadata.Tests
import qualified Hakyll.Web.RelativizeUrls.Tests
@@ -19,6 +20,8 @@ main = defaultMain
Hakyll.Core.Identifier.Tests.tests
, testGroup "Hakyll.Core.Routes.Tests"
Hakyll.Core.Routes.Tests.tests
+ , testGroup "Hakyll.Core.Rules.Tests"
+ Hakyll.Core.Rules.Tests.tests
, testGroup "Hakyll.Web.Page.Tests"
Hakyll.Web.Page.Tests.tests
, testGroup "Hakyll.Web.Page.Metadata.Tests"