use clap::{Parser, Subcommand};
use super::{CapsuleCommands, Cli, Commands};
#[test]
fn reserved_verbs_match_clap_subcommands() {
let cmd = CapsuleCommands::augment_subcommands(clap::Command::new("capsule"));
let clap_names: Vec<String> = cmd
.get_subcommands()
.map(|s| s.get_name().to_string())
.collect();
for name in &clap_names {
assert!(
astrid_core::kernel_api::RESERVED_CAPSULE_VERBS.contains(&name.as_str()),
"built-in `astrid capsule {name}` is missing from RESERVED_CAPSULE_VERBS \
(add it so a capsule cannot shadow it)"
);
}
assert!(astrid_core::kernel_api::RESERVED_CAPSULE_VERBS.contains(&"help"));
}
#[test]
fn capsule_update_parses_one_shot_untrusted_approval() {
let cli = Cli::try_parse_from([
"astrid",
"capsule",
"update",
"example",
"--approve-untrusted",
])
.expect("update should accept an explicit one-shot authority grant");
assert!(matches!(
cli.command,
Some(Commands::Capsule {
command: CapsuleCommands::Update {
target: Some(ref target),
workspace: false,
approve_untrusted: true,
},
}) if target == "example"
));
}