use super::{NOTICE_MARKERS, is_notice, looks_notice};
const SAMPLES: &[&str] = &[
"lernie: compaction landing [c-2] declined — git could not replay a.md \
(marked refs/lernie/conflicted/c-2, ARCH §2.6); the branch continues uncompacted",
"lernie: compaction landing [c-2] superseded — a compaction landed since its \
fork point (ARCH §2.6); the branch continues",
"lernie: retarget of [c-1] declined — git could not replay a.md (marked \
refs/lernie/conflicted/c-1, ARCH §2.6); the branch continues on its previous config",
"lernie: settling a crashed tool window on [c-1] — 2 unanswered invocation(s) \
recorded as died (ARCH §6, bl-4187)",
"lernie: exit launch for c-1: no such file (accepted crash class, ARCH §2.11)",
"lernie: revival launch for c-1: no such file (accepted crash class, ARCH §2.11)",
"lernie: post-release inbox re-read for c-1: no such file (accepted crash class, ARCH §2.11)",
"lernie: post-release launch for c-1: no such file (accepted crash class, ARCH §2.11)",
"lernie: budget exhausted on c-1; stopping (ARCH §6)",
];
#[test]
fn every_enumerated_lernie_notice_is_recognized() {
for line in SAMPLES {
assert!(looks_notice(line), "not recognized: {line}");
assert!(
looks_notice(&format!("{line}\n")),
"trailing newline: {line}"
);
}
}
#[test]
fn every_marker_in_the_table_is_exercised_by_a_sample() {
for marker in NOTICE_MARKERS {
assert!(
SAMPLES
.iter()
.any(|line| line.to_ascii_lowercase().contains(marker)),
"no sample exercises the marker {marker:?}"
);
}
}
#[test]
fn a_tail_of_several_notices_is_still_a_notice() {
let tail = format!("{}\n\n{}\n", SAMPLES[1], SAMPLES[4]);
assert!(looks_notice(&tail));
}
#[test]
fn a_tail_mixing_a_notice_with_anything_else_stays_a_failure() {
let death = "lernie: brazen 0.0.2 != 0.0.3";
assert!(!looks_notice(&format!("{}\n{death}\n", SAMPLES[1])));
assert!(!looks_notice(&format!("{death}\n{}\n", SAMPLES[1])));
}
#[test]
fn near_misses_are_not_notices() {
for line in [
"lernie prompt: provider error (Config) on provider row \"x\": unknown provider `x`",
"lernie: brazen 0.0.2 != 0.0.3",
"compaction landing [c-2] superseded (ARCH §2.6); the branch continues",
"refusing: version skew",
"lernie: setpgid: operation not permitted",
] {
assert!(!looks_notice(line), "wrongly benign: {line}");
}
}
#[test]
fn a_tail_with_no_lines_at_all_is_not_a_notice() {
assert!(!looks_notice(""));
assert!(!looks_notice("\n \n\t\n"));
}
#[test]
fn the_match_is_case_insensitive_and_ignores_leading_space() {
assert!(is_notice(
" LERNIE: BUDGET exhausted on c-1; STOPPING (ARCH §6)"
));
assert!(!is_notice(" LERNIE: something else entirely"));
}