Skip to content

Commit febb9b5

Browse files
committed
add tests
1 parent 67f8797 commit febb9b5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/file.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,21 @@ mod tests {
7878
let items = list_all_file_items(Path::new("doesnt_exist"));
7979
assert_eq!(0, items.len());
8080
}
81+
82+
#[test]
83+
fn test_get_file_items() {
84+
// Create a dummy directory structure for testing
85+
fs::create_dir_all("./test_dir/subdir").unwrap();
86+
fs::File::create("./test_dir/file1.txt").unwrap();
87+
fs::File::create("./test_dir/subdir/file2.txt").unwrap();
88+
89+
let line = "test_dir/subdir/";
90+
let root_folder = "./";
91+
let items = get_file_items(line, root_folder);
92+
93+
assert!(items.contains(&("file2.txt".to_string(), 15)));
94+
95+
// Clean up the dummy directory structure
96+
fs::remove_dir_all("./test_dir").unwrap();
97+
}
8198
}

0 commit comments

Comments
 (0)