From cd1fe8b49522b51c84a0f4fa84e66909f483d170 Mon Sep 17 00:00:00 2001 From: Chloe Brown Date: Tue, 6 Jul 2021 21:01:22 +0100 Subject: bug: Tests try to modify user home directory (#535) Fixes a bug where running `cargo test` would try to create a configuration file for the user. --- tests/arg_tests.rs | 24 ++++++++++++++++++++++++ tests/empty_config.toml | 1 + 2 files changed, 25 insertions(+) create mode 100644 tests/empty_config.toml (limited to 'tests') diff --git a/tests/arg_tests.rs b/tests/arg_tests.rs index 51d8f383..34db7cf4 100644 --- a/tests/arg_tests.rs +++ b/tests/arg_tests.rs @@ -13,6 +13,8 @@ fn get_binary_location() -> String { #[test] fn test_small_rate() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-r") .arg("249") .assert() @@ -25,6 +27,8 @@ fn test_small_rate() { #[test] fn test_large_default_time() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-t") .arg("18446744073709551616") .assert() @@ -37,6 +41,8 @@ fn test_large_default_time() { #[test] fn test_small_default_time() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-t") .arg("900") .assert() @@ -49,6 +55,8 @@ fn test_small_default_time() { #[test] fn test_large_delta_time() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-d") .arg("18446744073709551616") .assert() @@ -61,6 +69,8 @@ fn test_large_delta_time() { #[test] fn test_small_delta_time() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-d") .arg("900") .assert() @@ -73,6 +83,8 @@ fn test_small_delta_time() { #[test] fn test_large_rate() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-r") .arg("18446744073709551616") .assert() @@ -86,6 +98,8 @@ fn test_large_rate() { fn test_negative_rate() { // This test should auto fail due to how clap works Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-r") .arg("-1000") .assert() @@ -98,6 +112,8 @@ fn test_negative_rate() { #[test] fn test_invalid_rate() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-r") .arg("100-1000") .assert() @@ -108,6 +124,8 @@ fn test_invalid_rate() { #[test] fn test_conflicting_temps() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("-c") .arg("-f") .assert() @@ -120,6 +138,8 @@ fn test_conflicting_temps() { #[test] fn test_invalid_default_widget_1() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("--default_widget_type") .arg("fake_widget") .assert() @@ -130,6 +150,8 @@ fn test_invalid_default_widget_1() { #[test] fn test_invalid_default_widget_2() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("--default_widget_type") .arg("cpu") .arg("--default_widget_count") @@ -144,6 +166,8 @@ fn test_invalid_default_widget_2() { #[test] fn test_missing_default_widget_type() { Command::new(get_binary_location()) + .arg("-C") + .arg("./tests/empty_config.toml") .arg("--default_widget_count") .arg("3") .assert() diff --git a/tests/empty_config.toml b/tests/empty_config.toml new file mode 100644 index 00000000..b2c0f98b --- /dev/null +++ b/tests/empty_config.toml @@ -0,0 +1 @@ +# This config file is "empty" so running tests does not modify a user's home directory. -- cgit v1.2.3