Skip to content

Commit fec93fd

Browse files
committed
test addConfigFileContentWithParams
1 parent 203deed commit fec93fd

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_nested_cmd.nim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ template loadFile(T, file): untyped =
1919
Toml, InputFile(configFilePath / file), flags = {TomlInlineTableNewline}
2020
)
2121

22+
template loadContent(T, cont): untyped =
23+
proc (
24+
config: T, sources: ref SecondarySources
25+
) {.raises: [ConfigurationError].} =
26+
sources.addConfigFileContentWithParams(
27+
Toml, cont, flags = {TomlInlineTableNewline}
28+
)
29+
2230
type
2331
OuterCmd = enum
2432
noCommand
@@ -148,3 +156,18 @@ suite "test nested cmd toml":
148156
conf.innerCmd == InnerCmd.innerCmd2
149157
conf.outerArg1 == "toml outer-arg1"
150158
conf.innerArg2 == "toml inner-arg2"
159+
160+
test "subcommand outerCmd1 innerCmd2":
161+
let tomlCont = readFile(configFilePath / "nested_cmd.toml")
162+
let conf = TestConf.load(
163+
secondarySources = loadContent(TestConf, tomlCont),
164+
cmdLine = @[
165+
"outerCmd1",
166+
"innerCmd2"
167+
]
168+
)
169+
check:
170+
conf.cmd == OuterCmd.outerCmd1
171+
conf.innerCmd == InnerCmd.innerCmd2
172+
conf.outerArg1 == "toml outer-arg1"
173+
conf.innerArg2 == "toml inner-arg2"

0 commit comments

Comments
 (0)