Use longer file names in test

This commit is contained in:
David Cook 2020-01-26 15:45:35 -06:00
parent d461c12c83
commit a82049587c

View file

@ -201,29 +201,31 @@ fn test_directory() {
assert!(dir_path.metadata().unwrap().is_dir());
// Create some files inside the directory
let f1_path = dir_path.join("f1");
drop(File::create(&f1_path).unwrap());
let f2_path = dir_path.join("f2");
drop(File::create(&f2_path).unwrap());
let path_1 = dir_path.join("test_file_1");
drop(File::create(&path_1).unwrap());
let path_2 = dir_path.join("test_file_2");
drop(File::create(&path_2).unwrap());
// Test that the files are present inside the directory
let mut dir_iter = read_dir(&dir_path).unwrap();
let first_dir_entry = dir_iter.next().unwrap().unwrap();
let second_dir_entry = dir_iter.next().unwrap().unwrap();
assert!(
first_dir_entry.file_name() == "f1" || first_dir_entry.file_name() == "f2",
"File name was {:?} instead of f1 or f2",
first_dir_entry.file_name() == "test_file_1" ||
first_dir_entry.file_name() == "test_file_2",
"File name was {:?} instead of test_file_1 or test_file_2",
first_dir_entry.file_name(),
);
assert!(
second_dir_entry.file_name() == "f1" || second_dir_entry.file_name() == "f2",
"File name was {:?} instead of f1 or f2",
second_dir_entry.file_name() == "test_file_1" ||
second_dir_entry.file_name() == "test_file_2",
"File name was {:?} instead of test_file_1 or test_file_2",
second_dir_entry.file_name(),
);
assert!(dir_iter.next().is_none());
drop(dir_iter);
// Clean up the files in the directory
remove_file(&f1_path).unwrap();
remove_file(&f2_path).unwrap();
remove_file(&path_1).unwrap();
remove_file(&path_2).unwrap();
// Deleting the directory should succeed.
remove_dir(&dir_path).unwrap();