From d92e2099ccba3154f7b163de7b8133f3fabcf0dd Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 9 May 2024 00:44:52 +0800 Subject: [PATCH] test: add test for cli parser --- maa-cli/src/command.rs | 22 +++++++++++++++++++++- maa-cli/src/main.rs | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/maa-cli/src/command.rs b/maa-cli/src/command.rs index 02ab9d5c..7d7b8cbb 100644 --- a/maa-cli/src/command.rs +++ b/maa-cli/src/command.rs @@ -166,7 +166,7 @@ pub(crate) enum Command { #[command(flatten)] common: run::CommonArgs, }, - OperBox { + Operbox { #[command(flatten)] common: run::CommonArgs, }, @@ -681,6 +681,26 @@ mod test { ); } + #[test] + fn depot() { + assert_matches!( + parse_from(["maa", "depot"]).command, + Command::Depot { + common: run::CommonArgs { .. } + } + ); + } + + #[test] + fn operbox() { + assert_matches!( + parse_from(["maa", "operbox"]).command, + Command::Operbox { + common: run::CommonArgs { .. } + } + ); + } + #[test] fn convert() { assert_matches!( diff --git a/maa-cli/src/main.rs b/maa-cli/src/main.rs index 9e2aa9bd..db036b12 100644 --- a/maa-cli/src/main.rs +++ b/maa-cli/src/main.rs @@ -96,7 +96,7 @@ fn main() -> Result<()> { run::run(|_| run::preset::roguelike(theme), common)? } Command::Depot { common } => run::run(|_| run::preset::depot(), common)?, - Command::OperBox { common } => run::run(|_| run::preset::oper_box(), common)?, + Command::Operbox { common } => run::run(|_| run::preset::oper_box(), common)?, Command::Convert { input, output,