summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChloe Brown <chloe.brown.00@outlook.com>2021-07-06 21:01:22 +0100
committerChloe Brown <chloe.brown.00@outlook.com>2021-07-06 21:01:22 +0100
commitcd1fe8b49522b51c84a0f4fa84e66909f483d170 (patch)
tree5a3c17c13b032723e51713f83eebaf6bbebd456d /tests
parentf13905f78d0ece59ef86b06c83dc98f9abb6d3ea (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/arg_tests.rs24
-rw-r--r--tests/empty_config.toml1
2 files changed, 25 insertions, 0 deletions
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.