Skip to content

Commit

Permalink
test: add test for cli parser
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc committed May 8, 2024
1 parent 5272908 commit 1c31224
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion maa-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub(crate) enum Command {
#[command(flatten)]
common: run::CommonArgs,
},
OperBox {
Operbox {
#[command(flatten)]
common: run::CommonArgs,
},
Expand Down Expand Up @@ -666,6 +666,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!(
Expand Down
2 changes: 1 addition & 1 deletion maa-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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)?,

Check warning on line 97 in maa-cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/main.rs#L96-L97

Added lines #L96 - L97 were not covered by tests
Command::Convert {
input,
output,
Expand Down

0 comments on commit 1c31224

Please sign in to comment.