use std::path::PathBuf;
use alpm_pkgbuild::bridge::{BridgeOutput, run_bridge_script};
use alpm_srcinfo::SourceInfoV1;
use insta::assert_snapshot;
use rstest::rstest;
use testresult::TestResult;
#[rstest]
fn correct_files(#[files("tests/pkgbuild_correct/*.pkgbuild")] case: PathBuf) -> TestResult {
let test_name = case.file_stem().unwrap().to_str().unwrap().to_string();
let raw_bridge_output = run_bridge_script(&case)?;
insta::with_settings!({
description => format!("{test_name} PKGBUILD -> SRCINFO generation."),
snapshot_path => "pkgbuild_correct_bridge_output",
prepend_module_to_snapshot => false,
}, {
assert_snapshot!(format!("{test_name}_bridge"), raw_bridge_output);
});
let output = BridgeOutput::from_script_output(&raw_bridge_output)?;
let source_info: SourceInfoV1 = output.try_into()?;
let srcinfo_output = source_info.as_srcinfo();
insta::with_settings!({
description => format!("{test_name} PKGBUILD -> SRCINFO generation."),
snapshot_path => "pkgbuild_correct_snapshots",
prepend_module_to_snapshot => false,
}, {
assert_snapshot!(format!("{test_name}_srcinfo"), srcinfo_output );
});
Ok(())
}