Watch
0
0
Fork
You've already forked hyperhive
0

swarm-builder: an agent option whose eval failed is left out of the reply, not read as its default

This commit is contained in:
atlas 2026-11-06 10:03:18 +01:00 • committed by mara
commit 5d2b0c9a54

View file

@ -862,8 +862,8 @@ mod tests {
out_path: "/nix/store/x".to_owned(),
system: "s".to_owned(),
cached: false,
private_users: false,
nix_builds: hive_types::NixBuilds::Host,
private_users: Some(false),
nix_builds: Some(hive_types::NixBuilds::Host),
}
},
)
@ -885,8 +885,8 @@ mod tests {
out_path: "/nix/store/x".to_owned(),
system: "s".to_owned(),
cached: false,
private_users: false,
nix_builds: hive_types::NixBuilds::Host,
private_users: Some(false),
nix_builds: Some(hive_types::NixBuilds::Host),
}
},
)
@ -1454,7 +1454,9 @@ mod tests {
#[tokio::test]
async fn a_meta_build_is_answered_with_the_path_the_system_and_the_private_users_flag() {
let fake = meta_nix("echo true");
let fake = meta_nix(
"for a in \"$@\"; do last=$a; done; case \"$last\" in *nixBuilds) echo '\"host\"';; *) echo true;; esac",
);
let (env, mut sent) = env();
let request = msg(Some("_INBOX.5"), &meta_json("atlas", REV));
serve_meta(fake.builder(), env, vec![request]).await;
@ -1490,12 +1492,17 @@ mod tests {
);
}
/// An option the module does not declare is false; one whose eval failed, or
/// printed no bool, is left out of the reply, for the controller to record as
/// unknown. `echo false` is the control that the field is read at all.
#[tokio::test]
async fn private_users_is_false_unless_nix_eval_printed_true() {
for eval_says in [
"echo false",
"echo null",
"echo 'error: no such option' >&2; exit 1",
async fn private_users_is_left_out_unless_nix_eval_printed_a_bool_or_the_option_is_missing() {
let missing = "echo \"error: flake 'f' does not provide attribute 'a'\" >&2; exit 1";
for (eval_says, want) in [
("echo false", Some(false)),
(missing, Some(false)),
("echo null", None),
("echo 'error: no such option' >&2; exit 1", None),
] {
let fake = meta_nix(eval_says);
let (env, mut sent) = env();
@ -1503,7 +1510,12 @@ mod tests {
serve_meta(fake.builder(), env, vec![request]).await;
let (_, body) = next(&mut sent).await;
assert_eq!(body["state"], "built", "{eval_says}");
assert_eq!(body["private_users"], false, "{eval_says}");
assert_eq!(
body.get("private_users")
.and_then(serde_json::Value::as_bool),
want,
"{eval_says}: {body}"
);
}
}