Skip to content

Commit

Permalink
Add regression test for mdbook init title with no git config
Browse files Browse the repository at this point in the history
Regression test for #2485
  • Loading branch information
ehuss committed Nov 18, 2024
1 parent 9096012 commit 0c580c3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,26 @@ fn base_mdbook_init_can_skip_confirmation_prompts() {

assert!(!temp.path().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 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, None);
}

0 comments on commit 0c580c3

Please sign in to comment.