implement config file tests

This commit is contained in:
jangko 2020-11-02 16:02:35 +07:00 committed by zah
parent f3a048f9ea
commit 29c4a1870f
3 changed files with 63 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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()