hakyll/tests/Hakyll/Core/Routes/Tests.hs
Jasper Van der Jeugt fbc23ee892 Update test suite
2013-05-03 11:35:31 +02:00

44 lines
1.6 KiB
Haskell

--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Hakyll.Core.Routes.Tests
( tests
) where
--------------------------------------------------------------------------------
import Test.Framework (Test, testGroup)
import Test.HUnit (Assertion, (@=?))
--------------------------------------------------------------------------------
import Hakyll.Core.Identifier
import Hakyll.Core.Routes
import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.Routes.Tests" $ fromAssertions "runRoutes"
[ testRoutes "foo.html" (setExtension "html") "foo"
, testRoutes "foo.html" (setExtension ".html") "foo"
, testRoutes "foo.html" (setExtension "html") "foo.markdown"
, testRoutes "foo.html" (setExtension ".html") "foo.markdown"
, testRoutes "neve ro ddo reven"
(customRoute (reverse . toFilePath )) "never odd or even"
, testRoutes "foo" (constRoute "foo") "bar"
, testRoutes "tags/bar.xml" (gsubRoute "rss/" (const "")) "tags/rss/bar.xml"
, testRoutes "tags/bar.xml"
(gsubRoute "rss/" (const "") `composeRoutes` setExtension "xml")
"tags/rss/bar"
]
--------------------------------------------------------------------------------
testRoutes :: FilePath -> Routes -> Identifier -> Assertion
testRoutes expected r id' = do
(route, _) <- runRoutes r
(error "Hakyll.Core.Routes.Tests: no provider") id'
Just expected @=? route