use std::fs;
use mini_docs::Builder;
#[test]
fn build_produces_byte_exact_output_for_known_input_and_template() {
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("guide.md"),
"# Getting Started\n\nWelcome to the guide.\n",
)
.expect("write guide.md");
fs::write(
templates.path().join("page.html"),
"<!doctype html>\n<title>{{ page.title }}</title>\n<body>{{ page.content | safe }}</body>\n",
)
.expect("write page.html");
Builder::new(input.path())
.templates(templates.path())
.output(output.path())
.default_template("page.html")
.build()
.expect("build should succeed");
let written = fs::read_to_string(output.path().join("guide.html")).expect("read output file");
let expected = "<!doctype html>\n<title>Getting Started</title>\n<body><h1 id=\"getting-started\">Getting Started</h1>\n<p>Welcome to the guide.</p>\n</body>\n";
assert_eq!(written, expected);
}