use std::{fs::read_to_string, path::PathBuf};
use alpm_srcinfo::SourceInfoV1;
use insta::assert_snapshot;
use rstest::rstest;
use testresult::TestResult;
#[rstest]
fn ensure_parse_errors(#[files("tests/parse_errors/*")] case: PathBuf) -> TestResult {
let input = read_to_string(&case)?;
let result = SourceInfoV1::from_string(input.as_str());
let Err(error) = result else {
panic!("The parser succeeded even though it should've failed parsing.");
};
let name = case.file_stem().unwrap().to_str().unwrap();
let input_clone = input.clone();
insta::with_settings!({
description => input_clone,
snapshot_path => "parse_error_snapshots",
prepend_module_to_snapshot => false,
}, {
assert_snapshot!(name, format!("{error}"));
});
Ok(())
}