35 lines
889 B
Rust
35 lines
889 B
Rust
use clap::Parser;
|
|
use gitea_pr_review::cli::{Cli, Commands, OutputFormat};
|
|
|
|
#[test]
|
|
fn parse_fetch_default_format() {
|
|
let cli = Cli::try_parse_from(["gitea-pr-review", "fetch", "12"]).unwrap();
|
|
match cli.command {
|
|
Commands::Fetch(args) => {
|
|
assert_eq!(args.pr_index, 12);
|
|
assert_eq!(args.format, OutputFormat::Markdown);
|
|
assert!(args.out.is_none());
|
|
}
|
|
_ => panic!("expected fetch"),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn parse_render_md_requires_input() {
|
|
let cli = Cli::try_parse_from([
|
|
"gitea-pr-review",
|
|
"render-md",
|
|
"--in",
|
|
"sample.json",
|
|
])
|
|
.unwrap();
|
|
|
|
match cli.command {
|
|
Commands::RenderMd(args) => {
|
|
assert_eq!(args.input.display().to_string(), "sample.json");
|
|
assert!(args.out.is_none());
|
|
}
|
|
_ => panic!("expected render-md"),
|
|
}
|
|
}
|