aboutsummaryrefslogtreecommitdiffstats
path: root/tests/receptor.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 01:56:26 +0000
committertv <tv@krebsco.de>2026-12-01 02:20:48 +0000
commit05c9440fa6343bff8f0e93d76084d7d8365c70fa (patch)
treeafa61015470a06f5b141323df2d0a29687fcc3f6 /tests/receptor.rs
parentfe68d2951a59096cf7c9b3039c08bc587cef6530 (diff)
enstate: a setting the command doesn't use, as an argument, is an error
--state-dir and --run-dir with --pack, --systemctl but with --apply and --migrate, --unit but with --apply. From a configuration file, which holds them for every command, they are fine. The completion offers each command the settings it uses.
Diffstat (limited to 'tests/receptor.rs')
-rw-r--r--tests/receptor.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/receptor.rs b/tests/receptor.rs
index 56a1666..f8417a3 100644
--- a/tests/receptor.rs
+++ b/tests/receptor.rs
@@ -508,7 +508,11 @@ fn command_line() {
"--schema={}",
host.root.join("schema.json").display()
))
- .arg(format!("--systemctl={}", host.systemctl().display()))
+ .args(
+ arguments
+ .contains(&"--apply")
+ .then(|| format!("--systemctl={}", host.systemctl().display())),
+ )
.output()
.unwrap();
(
@@ -556,6 +560,17 @@ fn command_line() {
"{stdout}"
);
// Options not for the command, and two commands.
+ // Settings the command doesn't use, as arguments; from a file they are fine.
+ let (code, _, stderr) = enstate(&["--status", "--unit=x.service"]);
+ assert_eq!(code, Some(2));
+ assert!(stderr.contains("--unit is not for --status"), "{stderr}");
+ let (code, _, stderr) = enstate(&["--plan", missing, "--systemctl=/bin/true"]);
+ assert_eq!(code, Some(2));
+ assert!(stderr.contains("--systemctl is not for --plan"), "{stderr}");
+ std::fs::write(host.root.join("unit.json"), r#"{"unit": "x.service"}"#).unwrap();
+ let config = format!("--config={}", host.root.join("unit.json").display());
+ let (code, _, stderr) = enstate(&["--status", &config]);
+ assert_eq!(code, Some(0), "{stderr}");
let (code, _, stderr) = enstate(&["--status", "--out", "x"]);
assert_eq!(code, Some(2));
assert!(stderr.contains("--out is for --pack only"), "{stderr}");