Compare commits

...

2 Commits

Author SHA1 Message Date
andy.boot
3cce61f854 tests: add test for d0
Test to stop bug in previous commit occuring
Also cargo clippy
2025-07-28 22:35:40 +01:00
Yip Coekjan
222cd83ff3 Fix multi-paths output when depth is 0 2025-07-28 22:15:34 +01:00
2 changed files with 23 additions and 16 deletions

View File

@@ -32,8 +32,7 @@ pub fn get_biggest(
if number_top_level_nodes == 0 {
root = total_node_builder(0, vec![])
} else {
if number_top_level_nodes > 1 {
} else if number_top_level_nodes > 1 {
let size = if by_filetime.is_some() {
top_level_nodes
.iter()
@@ -46,9 +45,9 @@ pub fn get_biggest(
let nodes = handle_duplicate_top_level_names(top_level_nodes, display_data.short_paths);
root = total_node_builder(size, nodes);
heap = always_add_children(&display_data, &root, heap);
} else {
root = top_level_nodes.into_iter().next().unwrap();
}
heap = add_children(&display_data, &root, heap);
}

View File

@@ -62,6 +62,14 @@ pub fn test_d_flag_works() {
assert!(!output.contains("hello_file"));
}
#[test]
pub fn test_d0_works_on_multiple() {
// We should see the top level directory but not the sub dirs / files:
let output = build_command(vec!["-d", "0", "tests/test_dir/", "tests/test_dir2"]);
assert!(output.contains("test_dir "));
assert!(output.contains("test_dir2"));
}
#[test]
pub fn test_threads_flag_works() {
let output = build_command(vec!["-T", "1", "tests/test_dir/"]);