@@ -185,15 +185,15 @@ proc testConfigFile() =
185185
186186 test " basic config file" :
187187 let conf = TestConf .load (
188- envVarsPrefix= " prefix" ,
189- secondarySources = proc (
190- config: TestConf , sources: ref SecondarySources
191- ) {.raises : [ConfigurationError ].} =
192- if config.configFile.isSome:
193- sources.addConfigFile (Toml , config.configFile.get)
194- else :
195- sources.addConfigFile (Toml , InputFile (confPathCurrUser / " testVendor" / " testApp.toml" ))
196- sources.addConfigFile (Toml , InputFile (confPathSystemWide / " testVendor" / " testApp.toml" ))
188+ envVarsPrefix= " prefix" ,
189+ secondarySources = proc (
190+ config: TestConf , sources: ref SecondarySources
191+ ) {.raises : [ConfigurationError ].} =
192+ if config.configFile.isSome:
193+ sources.addConfigFile (Toml , config.configFile.get)
194+ else :
195+ sources.addConfigFile (Toml , InputFile (confPathCurrUser / " testVendor" / " testApp.toml" ))
196+ sources.addConfigFile (Toml , InputFile (confPathSystemWide / " testVendor" / " testApp.toml" ))
197197 )
198198
199199 # dataDir is in env var
@@ -207,4 +207,21 @@ proc testConfigFile() =
207207 check conf.logLevel == " TOML SW DEBUG"
208208 check conf.rpcPort.int == 1235
209209
210+ test " basic config file content" :
211+ let currUserCont = readFile (confPathCurrUser / " testVendor" / " testApp.toml" )
212+ let sysWideCont = readFile (confPathSystemWide / " testVendor" / " testApp.toml" )
213+ let conf = TestConf .load (
214+ envVarsPrefix= " prefix" ,
215+ secondarySources = proc (
216+ config: TestConf , sources: ref SecondarySources
217+ ) {.raises : [ConfigurationError ].} =
218+ sources.addConfigFileContent (Toml , currUserCont)
219+ sources.addConfigFileContent (Toml , sysWideCont)
220+ )
221+ check conf.dataDir.string == " ENV VAR DATADIR"
222+ check conf.logFile.isSome ()
223+ check conf.logFile.get ().string == " TOML CU LOGFILE"
224+ check conf.logLevel == " TOML SW DEBUG"
225+ check conf.rpcPort.int == 1235
226+
210227testConfigFile ()
0 commit comments