Migrate create_missing_file_with_config to BookTest
This commit is contained in:
parent
ba8107120c
commit
adcea9b3b9
4 changed files with 15 additions and 14 deletions
|
|
@ -348,20 +348,6 @@ fn check_link_target_fallback() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure a missing file is created if `create-missing` is true.
|
|
||||||
#[test]
|
|
||||||
fn create_missing_file_with_config() {
|
|
||||||
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 = true;
|
|
||||||
|
|
||||||
assert!(!temp.path().join("src").join("intro.md").exists());
|
|
||||||
let _md = MDBook::load_with_config(temp.path(), cfg).unwrap();
|
|
||||||
assert!(temp.path().join("src").join("intro.md").exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This makes sure you can include a Rust file with `{{#playground example.rs}}`.
|
/// This makes sure you can include a Rust file with `{{#playground example.rs}}`.
|
||||||
/// Specification is in `guide/src/format/rust.md`
|
/// Specification is in `guide/src/format/rust.md`
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,13 @@ fn failure_on_missing_file() {
|
||||||
"#]]);
|
"#]]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure a missing file is created if `create-missing` is true.
|
||||||
|
#[test]
|
||||||
|
fn create_missing() {
|
||||||
|
let test = BookTest::from_dir("build/create_missing");
|
||||||
|
assert!(test.dir.join("src/SUMMARY.md").exists());
|
||||||
|
assert!(!test.dir.join("src/chapter_1.md").exists());
|
||||||
|
test.load_book();
|
||||||
|
assert!(test.dir.join("src/chapter_1.md").exists());
|
||||||
|
}
|
||||||
|
|
|
||||||
2
tests/testsuite/build/create_missing/book.toml
Normal file
2
tests/testsuite/build/create_missing/book.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[book]
|
||||||
|
title = "create_missing"
|
||||||
3
tests/testsuite/build/create_missing/src/SUMMARY.md
Normal file
3
tests/testsuite/build/create_missing/src/SUMMARY.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
- [Chapter 1](./chapter_1.md)
|
||||||
Loading…
Add table
Reference in a new issue