2020-12-13 20:09:23 +01:00
|
|
|
module Structure (
|
|
|
|
test
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Arguments (Arguments(..))
|
|
|
|
import Blog (Path)
|
|
|
|
import qualified Blog.Path as Path (build)
|
|
|
|
import qualified Mock.Arguments as Arguments
|
|
|
|
import qualified Mock.Blog.Path as Path
|
|
|
|
import System.Directory (withCurrentDirectory)
|
2023-08-20 22:24:58 +02:00
|
|
|
import Test.HUnit (Test(..), assertEqual)
|
|
|
|
import Utils (labeled, testGroup)
|
2020-12-13 20:09:23 +01:00
|
|
|
|
2023-08-20 22:24:58 +02:00
|
|
|
checkPath :: Arguments -> Maybe Path -> Test
|
|
|
|
checkPath input expected = TestCase . withCurrentDirectory root $
|
|
|
|
either (\_ -> Nothing) Just <$> Path.build root input
|
|
|
|
>>= assertEqual "Incorrect path detected by hablo" expected
|
2020-12-13 20:09:23 +01:00
|
|
|
where
|
|
|
|
root = sourceDir input
|
|
|
|
|
|
|
|
test :: Test
|
2023-08-20 22:24:58 +02:00
|
|
|
test = testGroup "Blog structure" $ labeled
|
|
|
|
[ ("empty structure", checkPath Arguments.emptyBlog Nothing)
|
|
|
|
, ("default articles"
|
|
|
|
, checkPath Arguments.defaultArticles $ Just Path.defaultArticles)
|
|
|
|
, ("default pages", checkPath Arguments.defaultPages $ Just Path.defaultPages)
|
|
|
|
, ("both default", checkPath Arguments.bothDefault $ Just Path.bothDefault)
|
|
|
|
, ("custom articles"
|
|
|
|
, checkPath Arguments.customArticles $ Just Path.customArticles)
|
|
|
|
, ("custom pages", checkPath Arguments.customPages $ Just Path.customPages)
|
|
|
|
, ("both custom", checkPath Arguments.bothCustom $ Just Path.bothCustom)
|
|
|
|
, ("custom articles, default pages"
|
|
|
|
, (checkPath
|
|
|
|
Arguments.customArticlesDefaultPages
|
|
|
|
(Just Path.customArticlesDefaultPages)))
|
|
|
|
, ("custom pages, default articles"
|
|
|
|
, (checkPath
|
|
|
|
Arguments.customPagesDefaultArticles
|
|
|
|
(Just Path.customPagesDefaultArticles)))
|
|
|
|
, ("bad custom articles", checkPath Arguments.badCustomArticles $ Nothing)
|
|
|
|
, ("bad custom pages", checkPath Arguments.badCustomPages $ Nothing) ]
|