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("nested/nested.gmi"), "");
create_test_file(&test_dir.join("assets/style.css"), "");
#[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"), "");
// Verify file contents are identical
let original = fs::read(&file.path).unwrap();
- let copied = fs::read(&copied_path).unwrap();
+ let copied = fs::read(copied_path).unwrap();
assert_eq!(original, copied);
}
let output_dir = test_dir.join("output");
create_dir_all(&source_dir).expect("Could not create source test directory");
create_dir_all(&output_dir).expect("Could not create output test directory");
- create_dir_all(&source_dir.join("nested")).expect("Could not create source test directory");
+ create_dir_all(source_dir.join("nested")).expect("Could not create source test directory");
create_test_file(
&source_dir.join("nested/style.css"),
"* { margin: 0; padding: 0 }",
// Verify file contents are identical
let original = fs::read(&file.path).unwrap();
- let copied = fs::read(&copied_path).unwrap();
+ let copied = fs::read(copied_path).unwrap();
assert_eq!(original, copied);
}
// Verify file contents are identical
let original = fs::read(&file.path).unwrap();
- let copied = fs::read(&copied_path).unwrap();
+ let copied = fs::read(copied_path).unwrap();
assert_eq!(original, copied);
}
}
file_type: FileType::Gemini,
};
- strategy.handle_html(&source_dir, &output_dir, &file, &layout);
+ strategy.handle_html(&source_dir, &output_dir, &file, layout);
let html_output = output_dir.join("test.html");
assert!(html_output.exists());
let test_dir = setup_test_dir();
let source_dir = test_dir.join("source");
let output_dir = test_dir.join("output");
- create_dir_all(&source_dir.join("nested")).expect("Could not create source test directory");
+ create_dir_all(source_dir.join("nested")).expect("Could not create source test directory");
create_dir_all(&output_dir).expect("Could not create output test directory");
let layout = "\
<html>
file_type: FileType::Gemini,
};
- strategy.handle_html(&source_dir, &output_dir, &file, &layout);
+ strategy.handle_html(&source_dir, &output_dir, &file, layout);
let html_output = output_dir.join("nested/test.html");
assert!(html_output.exists());
let files = vec![
create_test_internal_file("test.gmi", FileType::Gemini),
create_test_internal_file(
- &layout_path.to_str().expect("Could not encode layout"),
+ layout_path.to_str().expect("Could not encode layout"),
FileType::Layout,
),
create_test_internal_file("regular.html", FileType::File),
#[test]
fn test_handle_with_layout() {
- let mut handler = FileHandler::default();
- handler.layout = Some("test layout".to_string());
+ let handler = FileHandler {
+ layout: Some("test layout".to_string()),
+ ..Default::default()
+ };
let test_dir = setup_test_dir();
- create_dir_all(&test_dir.join("output_html"))
+ create_dir_all(test_dir.join("output_html"))
.expect("Could not create output html test directory");
- create_dir_all(&test_dir.join("output_gemini"))
+ create_dir_all(test_dir.join("output_gemini"))
.expect("Could not create output gemini test directory");
let test_path = test_dir.join("test.gmi");
create_test_file(&test_path, "");
let file = create_test_internal_file(
- &test_path
+ test_path
.to_str()
.expect("Could not encode gemini test file"),
FileType::Gemini,
create_test_file(&test_dir.join("test1.gmi"), "");
create_test_file(&test_dir.join("test2.gmi"), "");
create_test_file(&test_dir.join("test3.gmi"), "");
- create_dir_all(&test_dir.join("output_html"))
+ create_dir_all(test_dir.join("output_html"))
.expect("Could not create output html test directory");
- create_dir_all(&test_dir.join("output_gemini"))
+ create_dir_all(test_dir.join("output_gemini"))
.expect("Could not create output gemini test directory");
let mut handler = FileHandler::default();
- let files = vec![
+ let files = [
create_test_internal_file(
- &test_dir
+ test_dir
.join("test1.gmi")
.to_str()
.expect("Could not encode test1"),
FileType::Gemini,
),
create_test_internal_file(
- &layout_path.to_str().expect("Could not encode layout"),
+ layout_path.to_str().expect("Could not encode layout"),
FileType::Layout,
),
create_test_internal_file(
- &test_dir
+ test_dir
.join("test2.gmi")
.to_str()
.expect("Could not encode test2"),
FileType::Gemini,
),
create_test_internal_file(
- &test_dir
+ test_dir
.join("test3.gmi")
.to_str()
.expect("Could not encode test3"),