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 Aug 18, 2024
1 parent 67fe54c commit d92e209
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 @@ -166,7 +166,7 @@ pub(crate) enum Command {
#[command(flatten)]
common: run::CommonArgs,
},
OperBox {
Operbox {
#[command(flatten)]
common: run::CommonArgs,
},
Expand Down Expand Up @@ -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!(
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 @@ -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)?,

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

View check run for this annotation

Codecov / codecov/patch

maa-cli/src/main.rs#L98-L99

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

0 comments on commit d92e209

Please sign in to comment.