use super::*;
#[test]
fn an_i8_rejection_shows_the_numbered_script_it_judged() {
let bad = "if true; do\n echo hi\nfi\n";
let err = validate_before_exec(bad).expect_err("bashrs should reject this");
assert!(
err.contains("the script bashrs judged"),
"the rejection does not show what was judged:\n{err}"
);
assert!(
err.contains("echo hi"),
"the rejection omits the script body, so the cited line cannot be found:\n{err}"
);
assert!(
err.contains(" 1 | "),
"the rejection is not line-numbered, so a rule's line number is unusable:\n{err}"
);
}
#[test]
fn a_passing_script_produces_no_diagnostic_dump() {
assert!(validate_before_exec("echo 'hello'\n").is_ok());
}
#[test]
fn an_i8_rejection_classifies_as_validation_not_connection() {
use crate::core::error::{ErrorClass, ForjarError};
let bad = "if true; do\n echo hi\nfi\n";
let err = validate_before_exec(bad).expect_err("bashrs should reject this");
let wrapped = format!("transport error: {err}");
assert!(
wrapped.contains("transport"),
"the wrapping this test exists to survive is missing:\n{wrapped}"
);
let classified = ForjarError::from_untyped(wrapped);
assert_eq!(classified.class(), ErrorClass::Validation);
assert_eq!(
classified.exit_code(),
3,
"a deterministic bashrs rejection must not exit 4 and tell CI to retry"
);
}
#[test]
fn the_dump_is_the_sanitised_text_not_the_original() {
let numbered = numbered_for_diagnosis("alpha\nbeta");
assert!(numbered.contains(" 1 | alpha"), "{numbered}");
assert!(numbered.contains(" 2 | beta"), "{numbered}");
}