hakyll/tests/Hakyll/Core/Routes/Tests.hs

44 lines
1.6 KiB
Haskell
Raw Normal View History

2012-11-26 15:11:37 +00:00
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Hakyll.Core.Routes.Tests
( tests
) where
2012-11-26 15:11:37 +00:00
--------------------------------------------------------------------------------
import Test.Framework (Test, testGroup)
2013-01-21 21:45:50 +00:00
import Test.HUnit (Assertion, (@=?))
2012-11-26 15:11:37 +00:00
--------------------------------------------------------------------------------
import Hakyll.Core.Identifier
import Hakyll.Core.Routes
import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.Routes.Tests" $ fromAssertions "runRoutes"
2013-01-21 21:45:50 +00:00
[ 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"
2011-02-28 21:40:23 +00:00
2013-01-21 21:45:50 +00:00
, testRoutes "neve ro ddo reven"
(customRoute (reverse . toFilePath )) "never odd or even"
2012-05-29 21:39:07 +00:00
2013-01-21 21:45:50 +00:00
, testRoutes "foo" (constRoute "foo") "bar"
2012-05-29 21:39:07 +00:00
2013-01-21 21:45:50 +00:00
, testRoutes "tags/bar.xml" (gsubRoute "rss/" (const "")) "tags/rss/bar.xml"
, testRoutes "tags/bar.xml"
(gsubRoute "rss/" (const "") `composeRoutes` setExtension "xml")
"tags/rss/bar"
]
2013-01-21 21:45:50 +00:00
--------------------------------------------------------------------------------
testRoutes :: FilePath -> Routes -> Identifier -> Assertion
testRoutes expected r id' = do
route <- runRoutes r (error "Hakyll.Core.Routes.Tests: no provider") id'
Just expected @=? route