Skip to content

Commit 64f991a

Browse files
committed
more tests
1 parent ab68a9d commit 64f991a

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

rust/functora-cfg/tests/integration.rs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,88 @@ fn cli_override() {
284284
};
285285
assert_eq!(lhs, rhs);
286286
}
287+
288+
#[test]
289+
#[serial]
290+
fn layered_override() {
291+
let mut file =
292+
NamedTempFile::with_suffix(".toml").unwrap();
293+
let text = r#"
294+
host = "192.168.0.10"
295+
logs = true
296+
[main_account]
297+
alias = "File Functora"
298+
balance = 100
299+
[sub_accounts.alice]
300+
alias = "File Alice"
301+
balance = 5
302+
"#;
303+
file.write_all(text.as_bytes()).unwrap();
304+
with_vars(
305+
vec![
306+
("FUNCTORA__PORT", Some("9090")),
307+
(
308+
"FUNCTORA__MAIN_ACCOUNT__BALANCE",
309+
Some("200"),
310+
),
311+
(
312+
"FUNCTORA__SUB_ACCOUNTS__ALICE__BALANCE",
313+
Some("50"),
314+
),
315+
],
316+
|| {
317+
let lhs = Cfg::new(Cli::parse_from([
318+
"functora",
319+
"--toml",
320+
&file.path().to_string_lossy().into_owned(),
321+
"--host",
322+
"10.10.10.10",
323+
"--logs",
324+
"false",
325+
"sub-account",
326+
"--alias",
327+
"Cli Bob",
328+
"--balance",
329+
"999",
330+
"--tags",
331+
"vip",
332+
"--tags",
333+
"beta",
334+
]));
335+
336+
let rhs = Cfg {
337+
host: "10.10.10.10".into(),
338+
port: 9090,
339+
logs: false,
340+
main_account: Account {
341+
alias: "File Functora".into(),
342+
balance: 200,
343+
tags: None,
344+
},
345+
sub_accounts: HashMap::from([
346+
(
347+
"alice".into(),
348+
Account {
349+
alias: "File Alice".into(),
350+
balance: 50,
351+
tags: None,
352+
},
353+
),
354+
(
355+
"0".into(),
356+
Account {
357+
alias: "Cli Bob".into(),
358+
balance: 999,
359+
tags: Some(vec![
360+
"vip".into(),
361+
"beta".into(),
362+
]),
363+
},
364+
),
365+
]),
366+
};
367+
368+
assert_eq!(lhs, rhs);
369+
},
370+
);
371+
}

0 commit comments

Comments
 (0)