chore: expand cli plan benchmark coverage

This commit is contained in:
Evandro Fonseca Junior committed 2026-03-26 19:03:46 -03:00
1 parent 50ee95ba1e
commit 501d39933f
1 file changed
+175 -1
+175 -1
View File
@@ -178,6 +178,44 @@ struct LogsArgs {
lines: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
enum CommandPlan {
SummaryOnly {
command: String,
},
ProbeStatus {
server: String,
api_key_present: bool,
format: OutputFormat,
},
ScanModels {
models_dir: String,
},
LoadModel {
models_dir: String,
model: String,
alias: Option<String>,
},
ConfigureAuth {
mode: AuthMode,
api_key: Option<String>,
},
SetConfig {
key: String,
value: String,
},
RunThroughputBench {
server: String,
api_key_present: bool,
samples: u32,
prompt_tokens: u32,
completion_tokens: u32,
},
ReadLogs {
lines: u32,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
println!("CLI scaffold ready for {}", render_command_summary(&cli));
@@ -194,6 +232,12 @@ fn render_command_summary(cli: &Cli) -> String {
)
}
fn plan_command(cli: &Cli) -> CommandPlan {
CommandPlan::SummaryOnly {
command: command_summary(&cli.command),
}
}
fn command_summary(command: &Commands) -> String {
match command {
Commands::Status => "status".to_owned(),
@@ -279,7 +323,7 @@ fn bench_command_summary(command: &BenchCommand) -> String {
#[cfg(test)]
mod tests {
use super::{render_command_summary, AuthMode, Cli, Commands};
use super::{plan_command, render_command_summary, AuthMode, Cli, CommandPlan, Commands};
use clap::Parser;
#[test]
@@ -475,4 +519,134 @@ mod tests {
other => panic!("unexpected command: {:?}", other),
}
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_status_plan_keeps_server_and_format() {
let cli = Cli::try_parse_from(["localllm", "--format", "json", "status"]).unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::ProbeStatus {
server: "http://127.0.0.1:8080".to_owned(),
api_key_present: false,
format: super::OutputFormat::Json,
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_models_scan_plan_uses_models_dir() {
let cli = Cli::try_parse_from(["localllm", "--models-dir", "D:/models", "models", "scan"])
.unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::ScanModels {
models_dir: "D:/models".to_owned(),
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_models_load_plan_preserves_alias_and_models_dir() {
let cli = Cli::try_parse_from([
"localllm",
"--models-dir",
"D:/models",
"models",
"load",
"qwen.gguf",
"--alias",
"qwen-coder",
])
.unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::LoadModel {
models_dir: "D:/models".to_owned(),
model: "qwen.gguf".to_owned(),
alias: Some("qwen-coder".to_owned()),
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_auth_enable_plan_preserves_mode_and_key() {
let cli = Cli::try_parse_from([
"localllm",
"auth",
"enable",
"--mode",
"protected",
"--api-key",
"secret",
])
.unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::ConfigureAuth {
mode: AuthMode::Protected,
api_key: Some("secret".to_owned()),
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_config_set_plan_preserves_key_value() {
let cli = Cli::try_parse_from(["localllm", "config", "set", "default_model", "qwen-coder"])
.unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::SetConfig {
key: "default_model".to_owned(),
value: "qwen-coder".to_owned(),
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_bench_throughput_plan_preserves_workload() {
let cli = Cli::try_parse_from([
"localllm",
"--api-key",
"secret",
"bench",
"throughput",
"--samples",
"5",
"--prompt-tokens",
"512",
"--completion-tokens",
"64",
])
.unwrap();
assert_eq!(
plan_command(&cli),
CommandPlan::RunThroughputBench {
server: "http://127.0.0.1:8080".to_owned(),
api_key_present: true,
samples: 5,
prompt_tokens: 512,
completion_tokens: 64,
}
);
}
#[test]
#[ignore = "autoresearch benchmark"]
fn cli_surface_logs_plan_preserves_line_limit() {
let cli = Cli::try_parse_from(["localllm", "logs", "--lines", "50"]).unwrap();
assert_eq!(plan_command(&cli), CommandPlan::ReadLogs { lines: 50 });
}
}