summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Poulter <sean.poulter@gmail.com>2023-04-03 23:00:40 -0400
committerSean Poulter <sean.poulter@gmail.com>2023-04-03 03:05:24 -0400
commitbffdb0b03d7b94af26083053191a4d77feb4fb1a (patch)
tree4cece1083185a411edddede3c11b3d9f11a959f7 /tests
parentb5ffc734a2dfcf225b26ff5fd94ca8e772293bf6 (diff)
fix(cli): init --force skips confirmation prompts
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/init.rs24
-rw-r--r--tests/cli/mod.rs1
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/cli/init.rs b/tests/cli/init.rs
new file mode 100644
index 00000000..7f992237
--- /dev/null
+++ b/tests/cli/init.rs
@@ -0,0 +1,24 @@
+use crate::cli::cmd::mdbook_cmd;
+use crate::dummy_book::DummyBook;
+
+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());
+}
diff --git a/tests/cli/mod.rs b/tests/cli/mod.rs
index 989f443f..152b4ee9 100644
--- a/tests/cli/mod.rs
+++ b/tests/cli/mod.rs
@@ -1,3 +1,4 @@
mod build;
mod cmd;
+mod init;
mod test;