Fix issues from running on root directory

clean up: 80338f4

Fixes -d flag to work again. Add test to stop regression
This commit is contained in:
Bob
2019-10-01 21:51:34 +01:00
parent 2ca2cebdad
commit 2f7a88e8dc
3 changed files with 26 additions and 31 deletions
+12 -14
View File
@@ -45,13 +45,7 @@ fn main_output(short_paths: bool) -> String {
{}
{}",
format_string("src/test_dir", true, short_paths, " 4.0K", "─┬"),
format_string(
"src/test_dir/many",
true,
short_paths,
" 4.0K",
" └─┬",
),
format_string("src/test_dir/many", true, short_paths, " 4.0K", " └─┬",),
format_string(
"src/test_dir/many/hello_file",
true,
@@ -77,13 +71,7 @@ fn main_output(short_paths: bool) -> String {
{}
{}",
format_string("src/test_dir", true, short_paths, " 12K", "─┬"),
format_string(
"src/test_dir/many",
true,
short_paths,
" 8.0K",
" └─┬",
),
format_string("src/test_dir/many", true, short_paths, " 8.0K", " └─┬",),
format_string(
"src/test_dir/many/hello_file",
true,
@@ -121,6 +109,16 @@ pub fn test_apparent_size() {
.unwrap();
}
#[test]
pub fn test_d_flag_works() {
// We should see the top level directory but not the sub dirs / files:
assert_cli::Assert::main_binary()
.with_args(&["-d", "1", "-s", "src/test_dir"])
.stdout()
.doesnt_contain("hello_file")
.unwrap();
}
fn build_temp_file(dir: &TempDir) -> (PathBuf) {
let file_path = dir.path().join("notes.txt");
let mut file = File::create(&file_path).unwrap();