use std::{fs::read_to_string, path::PathBuf};
use alpm_srcinfo::SourceInfoV1;
use pretty_assertions::assert_eq;
use rstest::rstest;
use testresult::TestResult;
#[rstest]
fn correct_writer(#[files("tests/correct/*.srcinfo")] case: PathBuf) -> TestResult {
let input = read_to_string(&case)?;
let source_info_result = SourceInfoV1::from_string(&input);
let source_info_result = match source_info_result {
Ok(result) => result,
Err(err) => {
panic!(
"The parser errored even though it should've succeeded the parsing step:\n{err}"
);
}
};
let source_info = source_info_result;
let output = source_info.as_srcinfo();
assert_eq!(
input, output,
"Input and generated SRCINFO output differ for file {case:?}"
);
Ok(())
}