diff --git a/tests/cli/init.rs b/tests/cli/init.rs deleted file mode 100644 index 2bdc6943..00000000 --- a/tests/cli/init.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::cli::cmd::mdbook_cmd; -use crate::dummy_book::DummyBook; - -use mdbook::config::Config; - -/// Run `mdbook init` with `--title` without git config. -/// -/// Regression test for https://github.com/rust-lang/mdBook/issues/2485 -#[test] -fn no_git_config_with_title() { - let temp = DummyBook::new().build().unwrap(); - - // doesn't exist before - assert!(!temp.path().join("book").exists()); - - let mut cmd = mdbook_cmd(); - cmd.args(["init", "--title", "Example title"]) - .current_dir(temp.path()) - .env("GIT_CONFIG_GLOBAL", "") - .env("GIT_CONFIG_NOSYSTEM", "1"); - 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.as_deref(), Some("Example title")); -} diff --git a/tests/cli/mod.rs b/tests/cli/mod.rs index 152b4ee9..989f443f 100644 --- a/tests/cli/mod.rs +++ b/tests/cli/mod.rs @@ -1,4 +1,3 @@ mod build; mod cmd; -mod init; mod test; diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 120a3037..b3a79022 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -99,3 +99,37 @@ src = "src" ); assert!(!test.dir.join(".gitignore").exists()); } + +// Run `mdbook init` with `--title` without git config. +// +// Regression test for https://github.com/rust-lang/mdBook/issues/2485 +#[test] +fn no_git_config_with_title() { + let mut test = BookTest::empty(); + test.run("init", |cmd| { + cmd.expect_stdout(str![[r#" + +Do you want a .gitignore to be created? (y/n) + +All done, no errors... + +"#]]) + .expect_stderr(str![[r#" +[TIMESTAMP] [INFO] (mdbook::book::init): Creating a new book with stub content + +"#]]) + .args(&["--title", "Example title"]); + }) + .check_file( + "book.toml", + str![[r#" +[book] +authors = [] +language = "en" +src = "src" +title = "Example title" + +"#]], + ); + assert!(!test.dir.join(".gitignore").exists()); +}