Skip to content

Commit 8357fca

Browse files
Add test for 404 file configured via output.html.input-404
1 parent ab08785 commit 8357fca

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

tests/testsuite/renderer.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,18 @@ fn render_404_with_custom_content() {
280280
str!["<p>I'm using contents in 404.md!</p>"],
281281
);
282282
}
283+
284+
/// Render a 404 error page with custom content provided by the file declared by output.html.input-404 in `book.toml`.
285+
/// This produces a 404 error page with the custom file name provided in the `input-404` field.
286+
#[test]
287+
fn render_404_from_custom_declared_file() {
288+
let mut test = BookTest::from_dir("renderer/render_404/explicitly_defined");
289+
test.check_main_file(
290+
"book/custom_404_filename.html",
291+
str!["<p>This is my 404 content in custom_404_filename.md</p>"],
292+
);
293+
294+
// Check that the custom 404.md file present is not used or copied to the book output directory.
295+
assert!(test.dir.join("src/404.md").exists());
296+
assert!(!test.dir.join("book/404.html").exists());
297+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[output.html]
2+
input-404 = "custom_404_filename.md"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm using contents in 404.md!

tests/testsuite/renderer/render_404/explicitly_defined/src/SUMMARY.md

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is my 404 content in custom_404_filename.md

0 commit comments

Comments
 (0)