use super::*;
const SAID: &str = "Author identity unknown\n\n\
*** Please tell me who you are.\n\n\
Run\n\n git config --global user.email \"you@example.com\"\n \
git config --global user.name \"Your Name\"\n\n\
to set your account's default identity.\n\
Omit --global to set the identity only in this repository.\n\n\
fatal: unable to auto-detect email address (got 'root@box.(none)')\n";
#[test]
fn gits_own_banner_becomes_the_named_prerequisite() {
let said = prerequisite(SAID).unwrap();
assert!(
said.starts_with("git has no identity on this box"),
"{said}"
);
assert!(said.contains("git config --global user.name"), "{said}");
assert!(said.contains("git config --global user.email"), "{said}");
assert!(
!said.contains('\n'),
"one sentence, never a capture: {said}"
);
}
#[test]
fn the_banner_answers_for_every_spelling_of_the_complaint() {
let committer = SAID
.replace("Author identity", "Committer identity")
.replace(
"unable to auto-detect email address (got 'root@box.(none)')",
"no email was given and auto-detection is disabled",
);
assert_eq!(prerequisite(&committer), Some(PREREQUISITE.to_owned()));
}
#[test]
fn another_failure_is_not_this_one() {
assert_eq!(prerequisite(""), None);
assert_eq!(
prerequisite("litany new: destination is not empty: /w/home\n"),
None
);
}