From e767be217a982ea3b54e4c4b4773058a9b244214 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Sep 2020 22:59:30 +0100 Subject: [PATCH] Add test for hidden flag --- tests/test_dir_hidden_entries/.hidden_file | 1 + tests/tests.rs | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/test_dir_hidden_entries/.hidden_file diff --git a/tests/test_dir_hidden_entries/.hidden_file b/tests/test_dir_hidden_entries/.hidden_file new file mode 100644 index 0000000..32f95c0 --- /dev/null +++ b/tests/test_dir_hidden_entries/.hidden_file @@ -0,0 +1 @@ +hi \ No newline at end of file diff --git a/tests/tests.rs b/tests/tests.rs index d087490..5d88583 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -344,3 +344,27 @@ pub fn test_with_bad_param() { let stderr = str::from_utf8(&stderr).unwrap(); assert!(stderr.contains("Did not have permissions for all directories")); } + +#[test] +pub fn test_hidden_flag() { + // Check we can see the hidden file normally + let mut cmd = Command::cargo_bin("dust").unwrap(); + let output = cmd + .arg("-c") + .arg("tests/test_dir_hidden_entries") + .unwrap() + .stdout; + let output = str::from_utf8(&output).unwrap(); + assert!(output.contains(".hidden_file")); + + // Check that adding the '-h' flag causes us to not see hidden files + let mut cmd = Command::cargo_bin("dust").unwrap(); + let output = cmd + .arg("-c") + .arg("-h") + .arg("tests/test_dir_hidden_entries") + .unwrap() + .stdout; + let output = str::from_utf8(&output).unwrap(); + assert!(!output.contains(".hidden_file")); +}