From 29c4a1870f91a3d61996d6eb32c5b25088d8ff97 Mon Sep 17 00:00:00 2001 From: jangko Date: Mon, 2 Nov 2020 16:02:35 +0700 Subject: [PATCH] implement config file tests --- .../current_user/testVendor/testApp.toml | 25 +++++++++++++++++++ .../system_wide/testVendor/testApp.toml | 25 +++++++++++++++++++ tests/test_config_file.nim | 13 ++++++++++ 3 files changed, 63 insertions(+) create mode 100644 tests/config_files/current_user/testVendor/testApp.toml create mode 100644 tests/config_files/system_wide/testVendor/testApp.toml diff --git a/tests/config_files/current_user/testVendor/testApp.toml b/tests/config_files/current_user/testVendor/testApp.toml new file mode 100644 index 0000000..70874cc --- /dev/null +++ b/tests/config_files/current_user/testVendor/testApp.toml @@ -0,0 +1,25 @@ +# curent user config file + +# logLevel = "TOML CU DEBUG" + +logFile = "TOML CU LOGFILE" + +dataDir = "TOML CU DATADIR" + +nonInteractive = true + +validators = ["TOML CU VALIDATORS 0"] + +validatorsDirFlag = "TOML CU VALIDATOR DIR" + +secretsDirFlag = "TOML CU SECRET DIR" + +graffiti = "0x00112233445566778899AABBCCDDEEFF" + +stopAtEpoch = 3 + +# rpcPort = 1234 + +rpcAddress = "1.1.1.1" + +retryDelay = 3 diff --git a/tests/config_files/system_wide/testVendor/testApp.toml b/tests/config_files/system_wide/testVendor/testApp.toml new file mode 100644 index 0000000..4b9c829 --- /dev/null +++ b/tests/config_files/system_wide/testVendor/testApp.toml @@ -0,0 +1,25 @@ +# system wide config file + +logLevel = "TOML SW DEBUG" + +logFile = "TOML SW LOGFILE" + +dataDir = "TOML SW DATADIR" + +nonInteractive = true + +validators = ["TOML SW VALIDATORS 0"] + +validatorsDirFlag = "TOML SW VALIDATOR DIR" + +secretsDirFlag = "TOML SW SECRET DIR" + +graffiti = "0x00112233445566778899AABBCCDDEEFF" + +stopAtEpoch = 3 + +rpcPort = 1235 + +rpcAddress = "1.1.1.1" + +retryDelay = 3 diff --git a/tests/test_config_file.nim b/tests/test_config_file.nim index f35f6cc..34c5b7c 100644 --- a/tests/test_config_file.nim +++ b/tests/test_config_file.nim @@ -196,7 +196,20 @@ proc readValue(r: var WinregReader, value: var GraffitiBytes) = proc testConfigFile() = suite "config file test suite": + putEnv("prefixdataDir", "ENV VAR DATADIR") + test "basic config file": let conf = TestConf.load() + # dataDir is in env var + check conf.dataDir.string == "ENV VAR DATADIR" + + # logFile is in current user config file + check conf.logFile.isSome() + check conf.logFile.get().string == "TOML CU LOGFILE" + + # logLevel and rpcPort are in system wide config file + check conf.logLevel == "TOML SW DEBUG" + check conf.rpcPort.int == 1235 + testConfigFile()