summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Nordholts <enselic@gmail.com>2021-02-28 15:05:41 +0100
committerDavid Peter <sharkdp@users.noreply.github.com>2021-02-28 18:09:44 +0100
commit643f0bcbe387f5e15a3c97bff5b12f9dc10285a6 (patch)
treea9c423c9d57a8cfbe0a82021dc8fc86f2e7b6824
parent9db9a38565ca8ed78a5ec2f3d0363d548d9249fb (diff)
integration_tests.rs: Add test config_location_when_generating
As a complement to #1556 to prevent #1550 from coming back. The test purposefully fails if ca60937c2e is reverted.
-rw-r--r--tests/integration_tests.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index 82473e91..4047d5c8 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -662,6 +662,30 @@ fn config_location_test() {
}
#[test]
+fn config_location_when_generating() {
+ let tmp_config_path = std::path::PathBuf::from("/tmp/should-be-created.conf");
+
+ // Make sure the file does not exist before the test is run
+ // If this fails, run the following before running tests:
+ // rm /tmp/should-be-created.conf
+ assert!(!tmp_config_path.exists());
+
+ // Create the file with bat
+ bat_with_config()
+ .env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
+ .arg("--generate-config-file")
+ .assert()
+ .success()
+ .stdout("Success! Config file written to /tmp/should-be-created.conf\n");
+
+ // Now we expect the file to exist. If it exists, we assume contents are correct
+ assert!(tmp_config_path.exists());
+
+ // Cleanup
+ std::fs::remove_file(tmp_config_path).unwrap();
+}
+
+#[test]
fn config_read_arguments_from_file() {
bat_with_config()
.env("BAT_CONFIG_PATH", "bat.conf")