use super::test_repo::TestRepo;
#[test]
fn given_warn_findings_when_fail_on_warn_then_exit_3() {
let repo = TestRepo::new();
repo.write_config(
r#"
[[rule]]
id = "custom.warn"
severity = "warn"
message = "Warn rule"
patterns = ["WARN_ME"]
paths = ["**/*.rs"]
"#,
);
repo.write_file("src/lib.rs", "WARN_ME\n");
let head_sha = repo.commit("add warn marker");
let result = repo.run_check_with_args(&head_sha, &["--no-default-rules", "--fail-on", "warn"]);
result.assert_exit_code(3);
let receipt = result.parse_receipt();
assert_eq!(receipt.warn_count(), 1);
assert_eq!(receipt.error_count(), 0);
}
#[test]
fn given_error_findings_when_fail_on_never_then_exit_0() {
let repo = TestRepo::new();
repo.write_config(
r#"
[[rule]]
id = "custom.error"
severity = "error"
message = "Error rule"
patterns = ["ERROR_ME"]
paths = ["**/*.rs"]
"#,
);
repo.write_file("src/lib.rs", "ERROR_ME\n");
let head_sha = repo.commit("add error marker");
let result = repo.run_check_with_args(&head_sha, &["--no-default-rules", "--fail-on", "never"]);
result.assert_exit_code(0);
let receipt = result.parse_receipt();
assert_eq!(receipt.error_count(), 1);
}