From b13189f2b9fd92a81da9fb001362d398fe3b3e12 Mon Sep 17 00:00:00 2001 From: Chris Pryer Date: Fri, 3 May 2024 15:32:58 -0400 Subject: [PATCH] Update insta-cmd and fix usage --- Cargo.lock | 4 +- crates/huak-cli/Cargo.toml | 2 +- crates/huak-cli/tests/mod.rs | 48 ++++++++++--------- .../snapshots/r#mod__tests__install_help.snap | 4 +- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07071fe4..9702bcfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -751,9 +751,9 @@ dependencies = [ [[package]] name = "insta-cmd" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809d3023d1d6e8d5c2206f199251f75cb26180e41f18cb0f22dd119161cb5127" +checksum = "ffeeefa927925cced49ccb01bf3e57c9d4cd132df21e576eb9415baeab2d3de6" dependencies = [ "insta", "serde", diff --git a/crates/huak-cli/Cargo.toml b/crates/huak-cli/Cargo.toml index b033e00e..dc32e25d 100644 --- a/crates/huak-cli/Cargo.toml +++ b/crates/huak-cli/Cargo.toml @@ -32,7 +32,7 @@ url = "2.5.0" [dev-dependencies] huak-dev = { path = "../huak-dev" } -insta-cmd = "0.4.0" +insta-cmd = "0.6.0" tempfile.workspace = true [lints] diff --git a/crates/huak-cli/tests/mod.rs b/crates/huak-cli/tests/mod.rs index b6bbe091..eafc213b 100644 --- a/crates/huak-cli/tests/mod.rs +++ b/crates/huak-cli/tests/mod.rs @@ -1,108 +1,108 @@ #[cfg(test)] mod tests { - use insta_cmd::assert_cmd_snapshot; + use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; use std::{path::PathBuf, process::Command}; #[test] fn test_activate_help() { - assert_cmd_snapshot!(Command::new("huak").arg("activate").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("activate").arg("--help")); } #[test] fn test_add_help() { - assert_cmd_snapshot!(Command::new("huak").arg("add").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("add").arg("--help")); } #[test] fn test_build_help() { - assert_cmd_snapshot!(Command::new("huak").arg("build").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("build").arg("--help")); } #[test] fn test_clean_help() { - assert_cmd_snapshot!(Command::new("huak").arg("clean").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("clean").arg("--help")); } #[test] fn test_completion_help() { - assert_cmd_snapshot!(Command::new("huak").arg("completion").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("completion").arg("--help")); } #[test] fn test_fix_help() { - assert_cmd_snapshot!(Command::new("huak").arg("fix").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("fix").arg("--help")); } #[test] fn test_fmt_help() { - assert_cmd_snapshot!(Command::new("huak").arg("fmt").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("fmt").arg("--help")); } #[test] fn test_help() { - assert_cmd_snapshot!(Command::new("huak").arg("help")); - assert_cmd_snapshot!(Command::new("huak").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("help")); + assert_cmd_snapshot!(Command::new(bin()).arg("--help")); } #[test] fn test_init_help() { - assert_cmd_snapshot!(Command::new("huak").arg("init").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("init").arg("--help")); } #[test] fn test_install_help() { - assert_cmd_snapshot!(Command::new("huak").arg("install").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("install").arg("--help")); } #[test] fn test_lint_help() { - assert_cmd_snapshot!(Command::new("huak").arg("lint").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("lint").arg("--help")); } #[test] fn test_new_help() { - assert_cmd_snapshot!(Command::new("huak").arg("new").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("new").arg("--help")); } #[test] fn test_publish_help() { - assert_cmd_snapshot!(Command::new("huak").arg("publish").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("publish").arg("--help")); } #[test] fn test_python_help() { - assert_cmd_snapshot!(Command::new("huak").arg("python").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("python").arg("--help")); } #[test] fn test_remove_help() { - assert_cmd_snapshot!(Command::new("huak").arg("remove").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("remove").arg("--help")); } #[test] fn test_run_help() { - assert_cmd_snapshot!(Command::new("huak").arg("run").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("run").arg("--help")); } #[test] fn test_test_help() { - assert_cmd_snapshot!(Command::new("huak").arg("test").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("test").arg("--help")); } #[test] fn test_update_help() { - assert_cmd_snapshot!(Command::new("huak").arg("update").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("update").arg("--help")); } #[test] fn test_version_help() { - assert_cmd_snapshot!(Command::new("huak").arg("version").arg("--help")); + assert_cmd_snapshot!(Command::new(bin()).arg("version").arg("--help")); } #[test] fn test_version() { let from = dev_resources_dir().join("mock-project"); - assert_cmd_snapshot!(Command::new("huak") + assert_cmd_snapshot!(Command::new(bin()) .arg("version") .arg("--no-color") .current_dir(from)); @@ -117,4 +117,8 @@ mod tests { .unwrap() .join("dev-resources") } + + fn bin() -> PathBuf { + get_cargo_bin("huak") + } } diff --git a/crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap b/crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap index 43de1904..7365010b 100644 --- a/crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap +++ b/crates/huak-cli/tests/snapshots/r#mod__tests__install_help.snap @@ -18,9 +18,9 @@ Arguments: Options: --python-version - The Python version to use. TODO(cnpryer): https://github.com/cnpryer/huak/issues/850 + The Python version to use --package-index-url - The package index to use. TODO(cnpryer): Deps (document this) [default: https://pypi.python.org/simple] + The package index to use [default: https://pypi.python.org/simple] -q, --quiet --no-color