on master help sign in
Add a test for byExtension
f5c9c6fJasper Van der Jeugt
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
2
2
3import Test.Framework (defaultMain, testGroup)
3import Test.Framework (defaultMain, testGroup)
4
4
5+import qualified Hakyll.Core.Compiler.Tests
5import qualified Hakyll.Core.DependencyAnalyzer.Tests
6import qualified Hakyll.Core.DependencyAnalyzer.Tests
6import qualified Hakyll.Core.Identifier.Tests
7import qualified Hakyll.Core.Identifier.Tests
7import qualified Hakyll.Core.Routes.Tests
8import qualified Hakyll.Core.Routes.Tests
@@ -19,7 +20,9 @@ import qualified Hakyll.Web.Util.Html.Tests
19
20
20main :: IO ()
21main :: IO ()
21main = defaultMain
22main = defaultMain
23+ [ testGroup "Hakyll.Core.Compiler.Tests"
24+ Hakyll.Core.Compiler.Tests.tests
22− [ testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
25+ , testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
23 Hakyll.Core.DependencyAnalyzer.Tests.tests
26 Hakyll.Core.DependencyAnalyzer.Tests.tests
24 , testGroup "Hakyll.Core.Identifier.Tests"
27 , testGroup "Hakyll.Core.Identifier.Tests"
25 Hakyll.Core.Identifier.Tests.tests
28 Hakyll.Core.Identifier.Tests.tests