chore: expand cli semantic benchmark coverage

This commit is contained in:
Evandro Fonseca Junior committed 2026-03-26 18:59:01 -03:00
1 parent d1dbc27031
commit a3f5585700
4 files changed
+121 -5

No files matched your search

+95 -5
View File
@@ -180,12 +180,16 @@ struct LogsArgs {
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
println!(
"CLI scaffold ready for {} at {}",
println!("CLI scaffold ready for {}", render_command_summary(&cli));
Ok(())
}
fn render_command_summary(cli: &Cli) -> String {
format!(
"command={} server={}",
command_summary(&cli.command),
cli.server
);
Ok(())
)
}
fn command_summary(command: &Commands) -> &'static str {
@@ -202,7 +206,7 @@ fn command_summary(command: &Commands) -> &'static str {
#[cfg(test)]
mod tests {
use super::Cli;
use super::{render_command_summary, AuthMode, Cli, Commands};
use clap::Parser;
#[test]
@@ -312,4 +316,90 @@ mod tests {
let parsed = Cli::try_parse_from(["localllm", "doctor"]);
assert!(parsed.is_ok());
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_status_summary_includes_output_contract() {
let cli = Cli::try_parse_from(["localllm", "--format", "json", "status"]).unwrap();
let summary = render_command_summary(&cli);
assert!(summary.contains("status"));
assert!(summary.contains("format=json"));
assert!(summary.contains("models_dir=./models"));
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_models_load_summary_includes_model_and_alias() {
let cli = Cli::try_parse_from([
"localllm",
"models",
"load",
"./models/qwen.gguf",
"--alias",
"qwen-coder",
])
.unwrap();
let summary = render_command_summary(&cli);
assert!(summary.contains("models.load"));
assert!(summary.contains("./models/qwen.gguf"));
assert!(summary.contains("alias=qwen-coder"));
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_auth_enable_summary_includes_mode_and_key_presence() {
let cli = Cli::try_parse_from([
"localllm",
"auth",
"enable",
"--mode",
"local-only",
"--api-key",
"secret",
])
.unwrap();
let summary = render_command_summary(&cli);
assert!(summary.contains("auth.enable"));
assert!(summary.contains("mode=local-only"));
assert!(summary.contains("has_api_key=true"));
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_bench_throughput_summary_includes_default_budget() {
let cli = Cli::try_parse_from(["localllm", "bench", "throughput"]).unwrap();
let summary = render_command_summary(&cli);
assert!(summary.contains("bench.throughput"));
assert!(summary.contains("samples=3"));
assert!(summary.contains("prompt_tokens=256"));
assert!(summary.contains("completion_tokens=128"));
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_logs_summary_includes_default_line_limit() {
let cli = Cli::try_parse_from(["localllm", "logs"]).unwrap();
let summary = render_command_summary(&cli);
assert!(summary.contains("logs"));
assert!(summary.contains("lines=200"));
}
#[test]
fn auth_mode_parser_accepts_local_only() {
let cli =
Cli::try_parse_from(["localllm", "auth", "enable", "--mode", "local-only"]).unwrap();
match cli.command {
Commands::Auth(auth) => match auth.command {
super::AuthSubcommand::Enable(args) => assert_eq!(args.mode, AuthMode::LocalOnly),
other => panic!("unexpected auth command: {:?}", other),
},
other => panic!("unexpected command: {:?}", other),
}
}
}