Skip to content

Commit

Permalink
単体テストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Oct 15, 2023
1 parent 7808c1c commit 396c036
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fs-err = { version = "2.9.0", features = ["tokio"] }
itertools = "0.10.5"
once_cell = "1.18.0"
regex = "1.10.0"
rstest = "0.15.0"
serde = { version = "1.0.145", features = ["derive"] }
serde_json = { version = "1.0.85", features = ["preserve_order"] }
strum = { version = "0.24.1", features = ["derive"] }
Expand Down
3 changes: 3 additions & 0 deletions crates/download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ tracing.workspace = true
tracing-subscriber.workspace = true
url = "2.3.0"
zip = "0.6.3"

[dev-dependencies]
rstest.workspace = true
27 changes: 27 additions & 0 deletions crates/download/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,30 @@ enum Stripping {
None,
FirstDir,
}

#[cfg(test)]
mod tests {
use clap::Parser as _;
use rstest::rstest;

use super::Args;

#[rstest]
#[case(&["", "--only", "core", "--exclude", "models"])]
#[case(&["", "--min", "--only", "core"])]
#[case(&["", "--min", "--exclude", "core"])]
fn it_denies_conflicting_options(#[case] args: &[&str]) {
let result = parse(args);
assert_eq!(Err(clap::error::ErrorKind::ArgumentConflict), result);
}

#[test]
fn it_denies_only_option_without_device_option() {
let result = parse(&["", "--only", "additional-libraries"]);
assert_eq!(Err(clap::error::ErrorKind::MissingRequiredArgument), result);
}

fn parse(args: &[&str]) -> Result<(), clap::error::ErrorKind> {
Args::try_parse_from(args).map(|_| ()).map_err(|e| e.kind())
}
}
2 changes: 1 addition & 1 deletion crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rev = "a16714ce16dec76fd0e3041a7acfa484921db3b5"
flate2 = "1.0.24"
heck = "0.4.0"
pretty_assertions = "1.3.0"
rstest = "0.15.0"
rstest.workspace = true
tar = "0.4.38"
test_util.workspace = true

Expand Down

0 comments on commit 396c036

Please sign in to comment.