Skip to content

Commit

Permalink
Issue #26: test that RUNTIME_IGNOREDOTFILES is respected
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Dimjašević committed Oct 28, 2019
1 parent 0b1bc80 commit aab53c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/Fencer/Rules/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (assertEqual, testCase)

import Fencer.Rules
import Fencer.Settings (getSettingsFromEnvironment, settingsIgnoreDotFiles)
import Fencer.Types


Expand All @@ -27,6 +28,7 @@ tests = testGroup "Rule tests"
, test_rulesLoadRulesNonYaml
, test_rulesLoadRulesRecursively
, test_rulesLoadRulesDotDirectory
, test_rulesLoadRulesRUNTIME_IGNOREDOTFILES
]

-- | A helper function for loading rules and making sure they are as
Expand Down Expand Up @@ -59,6 +61,25 @@ test_rulesLoadRulesDotDirectory =
loadRules ".fencer-config" True


-- | test that 'loadRulesFromDirectory' respects the
-- RUNTIME_IGNOREDOTFILES environment variable.
test_rulesLoadRulesRUNTIME_IGNOREDOTFILES :: TestTree
test_rulesLoadRulesRUNTIME_IGNOREDOTFILES =
testCase "Rules are not loaded from a dot-file" $ do
setEnv "RUNTIME_IGNOREDOTFILES" "true"
setEnv "RUNTIME_SUBDIRECTORY" "sub" -- this value will not be used anyway
settings <- getSettingsFromEnvironment
Temp.withSystemTempDirectory "fencer-config" $ \tempDir -> do
TIO.writeFile (tempDir </> "config1.yml") domain1Text
TIO.writeFile (tempDir </> ".config2.yaml") domain2Text
definitions <-
loadRulesFromDirectory
(#directory tempDir)
(#ignoreDotFiles $ settingsIgnoreDotFiles settings)
assertEqual "RUNTIME_IGNOREDOTFILES not respected!"
[domain1]
definitions

-- | Test that 'loadRulesFromDirectory' loads rules from all files, not just
-- YAML files.
--
Expand Down

0 comments on commit aab53c0

Please sign in to comment.