use super::*;
use crate::cli::clap::{parse_matches, parsed_options, render_help};
use std::ffi::OsString;
#[test]
fn every_status_subject_advertises_the_shared_options() {
for subject in [
OperationalStatusSubject::Node,
OperationalStatusSubject::NodeProvider,
OperationalStatusSubject::Subnet,
] {
let help = render_help(command(subject));
assert!(help.contains("--all"));
assert!(help.contains("--json"));
assert!(help.contains("--refresh"));
assert!(help.contains("--source-endpoint"));
assert!(help.contains("Cache-backed read"));
}
}
#[test]
fn status_options_parse_target_and_view_flags() {
let args = [
"tdb26",
"--all",
"--json",
"--refresh",
"--source-endpoint",
"https://example.test/api/v3",
];
let matches = parse_matches(
&mut command(OperationalStatusSubject::Subnet),
args.iter().map(OsString::from),
)
.expect("standalone status options");
let nested = parse_matches(
&mut crate::nns::subnet::subnet_command(),
std::iter::once("status").chain(args).map(OsString::from),
)
.expect("subnet status options");
let crate::nns::subnet::SubnetCommand::Status(nested) = parsed_options(&nested) else {
panic!("expected the status operation");
};
for options in [parsed_options(&matches), nested] {
let (format, request) =
status_request(options, "ic", PathBuf::from("/cache"), 1_780_531_200);
assert_eq!(request.view.target.as_deref(), Some("tdb26"));
assert_eq!(format, OutputFormat::Json);
assert!(request.view.include_all);
assert!(request.force_refresh);
assert_eq!(
request.refresh.source_endpoint,
"https://example.test/api/v3"
);
}
}