blob: 42d9d5f95b1fe77d27e5502608c8aade0875dcb3 [file] [log] [blame]
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +02001{-# LANGUAGE OverloadedStrings #-}
2
3module Mulkup.ConfigSpec (cases) where
4
5import Mulkup.Config
6import Mulkup.Prelude
7import Test.Tasty
8import Test.Tasty.HUnit
9
10cases :: TestTree
11cases =
12 testGroup
13 "ConfigSpec"
Matthias Andreas Benkard180d8532026-05-25 17:47:00 +020014 [unit_simpleConfig, unit_verboseOmitted]
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +020015
16unit_simpleConfig :: TestTree
17unit_simpleConfig = testCase "unit_simpleConfig" $ do
18 void $ readConfig exampleConfigText
19 where
20 exampleConfigText =
21 "\
22 \{ host = \"atmon\" \
23 \ \
Matthias Andreas Benkard180d8532026-05-25 17:47:00 +020024 \, verbose = False \
25 \ \
Matthias Andreas Benkard262110d2021-08-24 06:35:55 +020026 \, stashes = \
27 \ [ { name = \"mulk\" \
28 \ \
29 \ , baseDir = \"/Users/mulk\" \
30 \ \
31 \ , tiers = \
32 \ { hourly = { keep = 48 } \
33 \ , daily = { keep = 4 } \
34 \ , weekly = { keep = 4 } \
35 \ , monthly = { keep = 12 } \
36 \ } \
37 \ \
38 \ , exclusions = \
39 \ [ \
40 \ , \"**/.stack-work\" \
41 \ , \"**/dist-newstyle\" \
42 \ \
43 \ , \"~/.boot/cache\" \
44 \ , \"~/.cabal/bin\" \
45 \ , \"~/.cabal/packages\" \
46 \ , \"~/.cache\" \
47 \ ] \
48 \ } \
49 \ ] \
50 \}"
Matthias Andreas Benkard180d8532026-05-25 17:47:00 +020051
52unit_verboseOmitted :: TestTree
53unit_verboseOmitted = testCase "unit_verboseOmitted" $ do
54 config <- readConfig exampleConfigText
55 verbose config @?= False
56 where
57 exampleConfigText =
58 "\
59 \{ host = \"atmon\" \
60 \ \
61 \, stashes = \
62 \ [ { name = \"mulk\" \
63 \ , baseDir = \"/Users/mulk\" \
64 \ , tiers = \
65 \ { hourly = { keep = 1 } \
66 \ , daily = { keep = 1 } \
67 \ , weekly = { keep = 1 } \
68 \ , monthly = { keep = 1 } \
69 \ } \
70 \ , exclusions = [] : List Text \
71 \ } \
72 \ ] \
73 \}"