From 643f0bcbe387f5e15a3c97bff5b12f9dc10285a6 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 28 Feb 2021 15:05:41 +0100 Subject: [PATCH] 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. --- tests/integration_tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 @@ -661,6 +661,30 @@ fn config_location_test() { .stdout("not-existing.conf\n"); } +#[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()