on master help sign in
Add a test for byExtension
commitf5c9c6fa32cd330a0daa4d6cbff9fcae53d317cc authorJasper Van der Jeugt <m@jaspervdj.be> dateMon 13 Feb 2012, 22:40 (15 years ago) parent75b8c3e
2 files changed+39−1
tests/Hakyll/Core/Compiler/Tests.hs+35 tests/TestSuite.hs+4−1
tests/Hakyll/Core/Compiler/Tests.hsnew file+35
@@ -0,0 +1,35 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Hakyll.Core.Compiler.Tests
3+ where
4+
5+import qualified Data.Map as M
6+
7+import Test.Framework (Test)
8+import Test.Framework.Providers.HUnit (testCase)
9+import qualified Test.HUnit as H
10+
11+import Hakyll.Core.Compiler
12+import Hakyll.Core.Resource.Provider.Dummy
13+import Hakyll.Core.Util.Arrow
14+import TestSuite.Util
15+
16+tests :: [Test]
17+tests =
18+ [ testCase "byExtension" byExtensionTest
19+ ]
20+
21+byExtensionTest :: H.Assertion
22+byExtensionTest = do
23+ provider <- dummyResourceProvider $ M.empty
24+ txt <- runCompilerJobTest compiler "foo.txt" provider uni
25+ css <- runCompilerJobTest compiler "bar.css" provider uni
26+ html <- runCompilerJobTest compiler "qux.html" provider uni
27+ H.assertEqual "byExtension" "txt" txt
28+ H.assertEqual "byExtension" "css" css
29+ H.assertEqual "byExtension" "unknown" html
30+ where
31+ uni = ["foo.txt", "bar.css", "qux.html"]
32+ compiler = byExtension (constA ("unknown" :: String))
33+ [ (".txt", constA "txt")
34+ , (".css", constA "css")
35+ ]
tests/TestSuite.hs+4−1
@@ -2,6 +2,7 @@ module Main where
22
33import Test.Framework (defaultMain, testGroup)
44
5+import qualified Hakyll.Core.Compiler.Tests
56import qualified Hakyll.Core.DependencyAnalyzer.Tests
67import qualified Hakyll.Core.Identifier.Tests
78import qualified Hakyll.Core.Routes.Tests
@@ -19,7 +20,9 @@ import qualified Hakyll.Web.Util.Html.Tests
1920
2021main :: IO ()
2122main = defaultMain
22− [ testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
23+ [ testGroup "Hakyll.Core.Compiler.Tests"
24+ Hakyll.Core.Compiler.Tests.tests
25+ , testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
2326 Hakyll.Core.DependencyAnalyzer.Tests.tests
2427 , testGroup "Hakyll.Core.Identifier.Tests"
2528 Hakyll.Core.Identifier.Tests.tests