use markdown_contract::{FindingLevel, load_contract, validate};
const CONTRACT: &str = "\
mcVersion: 2
kind: contract
frontmatter:
type: object
required: [status]
properties:
status: { enum: [open, accepted] }
body:
order: strict
additionalSections: false
sections:
- section: Context
- section: Decision
";
const DOCUMENT: &str = "\
---
status: done
---
## Context
Config is checked by hand.
";
fn main() {
let contract = load_contract(CONTRACT).expect("the contract compiles");
let findings = validate(DOCUMENT, &contract, "decisions/zod.md");
for f in &findings {
let line = f.pos.map_or(0, |p| p.line);
println!("{}:{line} {:?} {}: {}", f.path, f.level, f.id, f.message);
}
let errors = findings
.iter()
.filter(|f| f.level == FindingLevel::Error)
.count();
assert_eq!(errors, 2);
}