Migrate failure_on_missing_file to BookTest
This commit is contained in:
parent
b9e433710d
commit
ba8107120c
4 changed files with 21 additions and 14 deletions
|
|
@ -348,20 +348,6 @@ fn check_link_target_fallback() {
|
|||
);
|
||||
}
|
||||
|
||||
/// Ensure building fails if `create-missing` is false and one of the files does
|
||||
/// not exist.
|
||||
#[test]
|
||||
fn failure_on_missing_file() {
|
||||
let temp = DummyBook::new().build().unwrap();
|
||||
fs::remove_file(temp.path().join("src").join("intro.md")).unwrap();
|
||||
|
||||
let mut cfg = Config::default();
|
||||
cfg.build.create_missing = false;
|
||||
|
||||
let got = MDBook::load_with_config(temp.path(), cfg);
|
||||
assert!(got.is_err());
|
||||
}
|
||||
|
||||
/// Ensure a missing file is created if `create-missing` is true.
|
||||
#[test]
|
||||
fn create_missing_file_with_config() {
|
||||
|
|
|
|||
|
|
@ -16,3 +16,16 @@ fn basic_build() {
|
|||
"#]]);
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure building fails if `create-missing` is false and one of the files does
|
||||
// not exist.
|
||||
#[test]
|
||||
fn failure_on_missing_file() {
|
||||
BookTest::from_dir("build/missing_file").run("build", |cmd| {
|
||||
cmd.expect_failure().expect_stderr(str![[r#"
|
||||
[TIMESTAMP] [ERROR] (mdbook::utils): Error: Chapter file not found, ./chapter_1.md
|
||||
[TIMESTAMP] [ERROR] (mdbook::utils): [TAB]Caused By: [NOT_FOUND]
|
||||
|
||||
"#]]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
5
tests/testsuite/build/missing_file/book.toml
Normal file
5
tests/testsuite/build/missing_file/book.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[book]
|
||||
title = "missing_file"
|
||||
|
||||
[build]
|
||||
create-missing = false
|
||||
3
tests/testsuite/build/missing_file/src/SUMMARY.md
Normal file
3
tests/testsuite/build/missing_file/src/SUMMARY.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Summary
|
||||
|
||||
- [Chapter 1](./chapter_1.md)
|
||||
Loading…
Add table
Reference in a new issue