blob: 42d9d5f95b1fe77d27e5502608c8aade0875dcb3 [file] [log] [blame]
{-# LANGUAGE OverloadedStrings #-}
module Mulkup.ConfigSpec (cases) where
import Mulkup.Config
import Mulkup.Prelude
import Test.Tasty
import Test.Tasty.HUnit
cases :: TestTree
cases =
testGroup
"ConfigSpec"
[unit_simpleConfig, unit_verboseOmitted]
unit_simpleConfig :: TestTree
unit_simpleConfig = testCase "unit_simpleConfig" $ do
void $ readConfig exampleConfigText
where
exampleConfigText =
"\
\{ host = \"atmon\" \
\ \
\, verbose = False \
\ \
\, stashes = \
\ [ { name = \"mulk\" \
\ \
\ , baseDir = \"/Users/mulk\" \
\ \
\ , tiers = \
\ { hourly = { keep = 48 } \
\ , daily = { keep = 4 } \
\ , weekly = { keep = 4 } \
\ , monthly = { keep = 12 } \
\ } \
\ \
\ , exclusions = \
\ [ \
\ , \"**/.stack-work\" \
\ , \"**/dist-newstyle\" \
\ \
\ , \"~/.boot/cache\" \
\ , \"~/.cabal/bin\" \
\ , \"~/.cabal/packages\" \
\ , \"~/.cache\" \
\ ] \
\ } \
\ ] \
\}"
unit_verboseOmitted :: TestTree
unit_verboseOmitted = testCase "unit_verboseOmitted" $ do
config <- readConfig exampleConfigText
verbose config @?= False
where
exampleConfigText =
"\
\{ host = \"atmon\" \
\ \
\, stashes = \
\ [ { name = \"mulk\" \
\ , baseDir = \"/Users/mulk\" \
\ , tiers = \
\ { hourly = { keep = 1 } \
\ , daily = { keep = 1 } \
\ , weekly = { keep = 1 } \
\ , monthly = { keep = 1 } \
\ } \
\ , exclusions = [] : List Text \
\ } \
\ ] \
\}"