From 067be4fc93ba9c9806ea5c5e363c13fb9a6a1ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Tue, 29 Oct 2019 09:38:23 +0100 Subject: [PATCH] Issue #26: implements Artyom's feedback for RUNTIME_IGNOREDOTFILES tests --- test/Fencer/Rules/Test.hs | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/test/Fencer/Rules/Test.hs b/test/Fencer/Rules/Test.hs index 961e093..003e33d 100644 --- a/test/Fencer/Rules/Test.hs +++ b/test/Fencer/Rules/Test.hs @@ -29,7 +29,8 @@ tests = testGroup "Rule tests" , test_rulesLoadRulesNonYaml , test_rulesLoadRulesRecursively , test_rulesLoadRulesDotDirectory - , test_rulesLoadRulesRUNTIME_IGNOREDOTFILES + , test_rulesLoadRulesRUNTIME_IGNOREDOTFILEStrue + , test_rulesLoadRulesRUNTIME_IGNOREDOTFILESfalse ] -- | Create given directory structure and check that 'loadRulesFromDirectory' @@ -75,24 +76,37 @@ test_rulesLoadRulesDotDirectory = expectLoadRules (#ignoreDotFiles True) (#files - [ (".domain1/config1.yml", domain1Text) - , (".domain2/config2.yaml", domain2Text) ] + [ (".domain1" "config1.yml", domain1Text) + , (".domain2" "config2.yaml", domain2Text) ] ) (#result [domain1, domain2]) --- | test that 'loadRulesFromDirectory' respects the --- RUNTIME_IGNOREDOTFILES environment variable. -test_rulesLoadRulesRUNTIME_IGNOREDOTFILES :: TestTree -test_rulesLoadRulesRUNTIME_IGNOREDOTFILES = +-- | test that 'loadRulesFromDirectory' correctly implements the case +-- RUNTIME_IGNOREDOTFILES=true. +test_rulesLoadRulesRUNTIME_IGNOREDOTFILEStrue :: TestTree +test_rulesLoadRulesRUNTIME_IGNOREDOTFILEStrue = testCase "Rules are not loaded from a dot-file" $ do expectLoadRules (#ignoreDotFiles True) (#files [ ("config1.yml", domain1Text) - , ("dir/.config2.yaml", domain2Text) ] + , ("dir" ".config2.yaml", domain2Text) ] ) (#result [domain1]) +-- | test that 'loadRulesFromDirectory' correctly implements the case +-- RUNTIME_IGNOREDOTFILES=false. +test_rulesLoadRulesRUNTIME_IGNOREDOTFILESfalse :: TestTree +test_rulesLoadRulesRUNTIME_IGNOREDOTFILESfalse = + testCase "Rules are not loaded from a dot-file" $ do + expectLoadRules + (#ignoreDotFiles False) + (#files + [ ("config1.yml", domain1Text) + , ("dir" ".config2.yaml", domain2Text) ] + ) + (#result [domain1, domain2]) + -- | Test that 'loadRulesFromDirectory' loads rules from all files, not just -- YAML files. -- @@ -117,8 +131,8 @@ test_rulesLoadRulesRecursively = expectLoadRules (#ignoreDotFiles True) (#files - [ ("domain1/config.yml", domain1Text) - , ("domain2/config/config.yml", domain2Text) ] + [ ("domain1" "config.yml", domain1Text) + , ("domain2" "config" "config.yml", domain2Text) ] ) (#result [domain1, domain2])