Skip to content

Commit f63432c

Browse files
Add test for init where a git username is present
1 parent 153bbe8 commit f63432c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/testsuite/init.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,23 @@ All done, no errors...
288288
});
289289
assert!(!test.dir.join(".gitignore").exists());
290290
}
291+
292+
/// Run `mdbook init` with a custom gitconfig file which contains an author name
293+
#[test]
294+
fn init_obtains_author_from_gitconfig() {
295+
let mut test = BookTest::from_dir("init/init_with_gitconfig");
296+
test.run("init", |cmd| {
297+
let git_config_path = cmd.dir.join("gitconfig_with_user_name.gitconfig");
298+
cmd.env("GIT_CONFIG_GLOBAL", git_config_path.to_str().unwrap());
299+
})
300+
.check_file(
301+
"book.toml",
302+
str![[r#"
303+
[book]
304+
authors = ["mdBook gitconfig author"]
305+
language = "en"
306+
src = "src"
307+
308+
"#]],
309+
);
310+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[user]
2+
name = "mdBook gitconfig author"

0 commit comments

Comments
 (0)