cargo/crates/mdman/tests/invalid.rs
Ed Page 96f8517a28 test(mdman): Switch to snapbox
- We use it elsewhere
- We don't have to bake our own snapshotting solution
- It is more obvious how to update the snapshots
2023-12-01 15:31:27 -06:00

35 lines
851 B
Rust

//! Tests for errors and invalid input.
use std::path::PathBuf;
use mdman::{Format, ManMap};
fn run(name: &str, expected_error: &str) {
let input = PathBuf::from(format!("tests/invalid/{}", name));
match mdman::convert(&input, Format::Man, None, ManMap::new()) {
Ok(_) => {
panic!("expected {} to fail", name);
}
Err(e) => {
snapbox::assert_eq(expected_error, e.to_string());
}
}
}
macro_rules! test( ($name:ident, $file_name:expr, $error:expr) => (
#[test]
fn $name() { run($file_name, $error); }
) );
test!(
nested,
"nested.md",
"Error rendering \"template\" line 4, col 1: options blocks cannot be nested"
);
test!(
not_inside_options,
"not-inside-options.md",
"Error rendering \"template\" line 3, col 1: option must be in options block"
);