aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoris2016-03-18 09:50:39 +0100
committerJoris2016-03-18 09:50:39 +0100
commitbf804f73ce3494be430054499c5ce18f232f68ca (patch)
tree6b89c204b9f997d6f6d4134cfaa72ecc6f2234f6 /tests
parent9c3c43835addc950c3af7fab8fd53e24e7e29ad9 (diff)
Add optional imports
Diffstat (limited to 'tests')
-rw-r--r--tests/Helper.hs2
-rw-r--r--tests/Test.hs11
2 files changed, 11 insertions, 2 deletions
diff --git a/tests/Helper.hs b/tests/Helper.hs
index 3dcc267..00bccc9 100644
--- a/tests/Helper.hs
+++ b/tests/Helper.hs
@@ -14,7 +14,7 @@ import qualified Data.Text.IO as T
import Data.Maybe (fromJust)
import Data.ConfigManager
-import Data.ConfigManager.Config
+import Data.ConfigManager.Types (Config)
forceGetConfig :: Text -> IO Config
forceGetConfig = (fmap fromJust) . getConfig
diff --git a/tests/Test.hs b/tests/Test.hs
index 957f3ae..03dc979 100644
--- a/tests/Test.hs
+++ b/tests/Test.hs
@@ -14,7 +14,7 @@ import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
import Data.ConfigManager
-import Data.ConfigManager.Config
+import Data.ConfigManager.Types (Config(..))
import qualified Data.Text as T
import Helper (forceGetConfig, getConfig, eitherToMaybe)
@@ -115,3 +115,12 @@ importAssertion = do
assertEqual "d" (Just "zap") (lookup "d" config :: Maybe String)
assertEqual "e" (Just "re nam") (lookup "e" config :: Maybe String)
assertEqual "f" (Just 8.5) (lookup "f" config :: Maybe Double)
+
+ missingConfig <- getConfig "import \"required.conf\""
+ assertEqual "missing config" Nothing missingConfig
+
+ missingOptionalConfig <- forceGetConfig $ T.unlines
+ [ "importMaybe \"required.conf\""
+ , "x = 4"
+ ]
+ assertEqual "missing optional config" (Just 4) (lookup "x" missingOptionalConfig :: Maybe Int)