continue;
}
if path.is_dir() {
- result.append(&mut find_files_recursively(root_path, &path))
+ result.append(&mut find_files_recursively(root_path, &path));
} else {
let file_type = file_handler.identify(&path);
result.push(File { path, file_type });
use crate::file_handler::FileType;
use test_utilities::*;
- fn get_paths(root_directory: &PathBuf, files: &Vec<File>) -> HashSet<String> {
+ fn get_paths(root_directory: &PathBuf, files: &[File]) -> HashSet<String> {
files
.iter()
.map(|file| {
#[test]
fn finds_all_files() {
let test_dir = setup_test_dir();
- create_dir_all(&test_dir.join("nested")).expect("Could not create nested test directory");
- create_dir_all(&test_dir.join("assets")).expect("Could not create assets test directory");
+ create_dir_all(test_dir.join("nested")).expect("Could not create nested test directory");
+ create_dir_all(test_dir.join("assets")).expect("Could not create assets test directory");
create_test_file(&test_dir.join("test1.gmi"), "");
create_test_file(&test_dir.join("_layout.html"), "");
create_test_file(&test_dir.join("nested/nested.gmi"), "");
#[test]
fn identifies_correct_file_types() {
let test_dir = setup_test_dir();
- create_dir_all(&test_dir.join("nested")).expect("Could not create nested test directory");
- create_dir_all(&test_dir.join("assets")).expect("Could not create assets test directory");
+ create_dir_all(test_dir.join("nested")).expect("Could not create nested test directory");
+ create_dir_all(test_dir.join("assets")).expect("Could not create assets test directory");
create_test_file(&test_dir.join("_layout.html"), "");
+ create_test_file(&test_dir.join("notalayout.html"), "");
create_test_file(&test_dir.join("nested/nested.gmi"), "");
create_test_file(&test_dir.join("assets/style.css"), "");
create_test_file(&test_dir.join("image.png"), "");
Some("gmi") => assert_eq!(file.file_type, FileType::Gemini),
Some("html") => {
if file.path.ends_with("_layout.html") {
- assert_eq!(file.file_type, FileType::Layout)
+ assert_eq!(file.file_type, FileType::Layout);
} else {
- assert_eq!(file.file_type, FileType::File)
+ assert_eq!(file.file_type, FileType::File);
}
}
_ => assert_eq!(file.file_type, FileType::File),
#[test]
fn ignores_git_directory() {
let test_dir = setup_test_dir();
- create_dir_all(&test_dir.join("nested")).expect("Could not create nested test directory");
- create_dir_all(&test_dir.join("assets")).expect("Could not create assets test directory");
- create_dir_all(&test_dir.join(".git")).expect("Could not create git test directory");
+ create_dir_all(test_dir.join("nested")).expect("Could not create nested test directory");
+ create_dir_all(test_dir.join("assets")).expect("Could not create assets test directory");
+ create_dir_all(test_dir.join(".git")).expect("Could not create git test directory");
create_test_file(&test_dir.join("_layout.html"), "");
create_test_file(&test_dir.join("nested/nested.gmi"), "");
create_test_file(&test_dir.join("assets/style.css"), "");