use std::fs;
use mini_docs::Builder;
#[test]
fn build_mirrors_nested_input_structure_as_html() {
let input = tempfile::tempdir().expect("create input tempdir");
let templates = tempfile::tempdir().expect("create templates tempdir");
let output = tempfile::tempdir().expect("create output tempdir");
fs::write(input.path().join("index.md"), "# Home").expect("write index.md");
fs::create_dir_all(input.path().join("guide")).expect("create guide dir");
fs::write(input.path().join("guide").join("setup.md"), "# Setup").expect("write setup.md");
fs::write(
templates.path().join("page.html"),
"{{ page.content | safe }}",
)
.expect("write page.html");
Builder::new(input.path())
.templates(templates.path())
.output(output.path())
.default_template("page.html")
.build()
.expect("build should succeed");
assert!(output.path().join("index.html").is_file());
assert!(output.path().join("guide").join("setup.html").is_file());
}
#[test]
fn build_with_no_markdown_files_writes_nothing() {
let input = tempfile::tempdir().expect("create input tempdir");
let templates = tempfile::tempdir().expect("create templates tempdir");
let output = tempfile::tempdir().expect("create output tempdir");
Builder::new(input.path())
.templates(templates.path())
.output(output.path())
.build()
.expect("build should succeed");
let entries: Vec<_> = fs::read_dir(output.path())
.expect("read output dir")
.collect();
assert!(entries.is_empty());
}