Migrate base_mdbook_init_can_skip_confirmation_prompts to BookTest
This commit is contained in:
parent
6fdd7b4a17
commit
41bfbc69e6
2 changed files with 28 additions and 20 deletions
|
|
@ -3,26 +3,6 @@ use crate::dummy_book::DummyBook;
|
||||||
|
|
||||||
use mdbook::config::Config;
|
use mdbook::config::Config;
|
||||||
|
|
||||||
/// Run `mdbook init` with `--force` to skip the confirmation prompts
|
|
||||||
#[test]
|
|
||||||
fn base_mdbook_init_can_skip_confirmation_prompts() {
|
|
||||||
let temp = DummyBook::new().build().unwrap();
|
|
||||||
|
|
||||||
// doesn't exist before
|
|
||||||
assert!(!temp.path().join("book").exists());
|
|
||||||
|
|
||||||
let mut cmd = mdbook_cmd();
|
|
||||||
cmd.args(["init", "--force"]).current_dir(temp.path());
|
|
||||||
cmd.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(predicates::str::contains("\nAll done, no errors...\n"));
|
|
||||||
|
|
||||||
let config = Config::from_disk(temp.path().join("book.toml")).unwrap();
|
|
||||||
assert_eq!(config.book.title, None);
|
|
||||||
|
|
||||||
assert!(!temp.path().join(".gitignore").exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run `mdbook init` with `--title` without git config.
|
/// Run `mdbook init` with `--title` without git config.
|
||||||
///
|
///
|
||||||
/// Regression test for https://github.com/rust-lang/mdBook/issues/2485
|
/// Regression test for https://github.com/rust-lang/mdBook/issues/2485
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,31 @@ src/chapter_1.md
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run `mdbook init` with `--force` to skip the confirmation prompts
|
||||||
|
#[test]
|
||||||
|
fn init_force() {
|
||||||
|
let mut test = BookTest::empty();
|
||||||
|
test.run("init --force", |cmd| {
|
||||||
|
cmd.expect_stdout(str![[r#"
|
||||||
|
|
||||||
|
All done, no errors...
|
||||||
|
|
||||||
|
"#]])
|
||||||
|
.expect_stderr(str![[r#"
|
||||||
|
[TIMESTAMP] [INFO] (mdbook::book::init): Creating a new book with stub content
|
||||||
|
|
||||||
|
"#]]);
|
||||||
|
})
|
||||||
|
.check_file(
|
||||||
|
"book.toml",
|
||||||
|
str![[r#"
|
||||||
|
[book]
|
||||||
|
authors = []
|
||||||
|
language = "en"
|
||||||
|
src = "src"
|
||||||
|
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
assert!(!test.dir.join(".gitignore").exists());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue