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.
This commit is contained in:
Martin Nordholts 2021-02-28 15:05:41 +01:00 committed by David Peter
parent 9db9a38565
commit 643f0bcbe3

View File

@ -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()