use std::path::PathBuf;
use alpm_pkgbuild::bridge::{BridgeOutput, run_bridge_script};
use alpm_srcinfo::{SourceInfoV1, pkgbuild_bridge::error::BridgeError};
use insta::assert_snapshot;
use rstest::rstest;
use testresult::TestResult;
#[rstest]
fn invalid_files(#[files("tests/pkgbuild_invalid/*.pkgbuild")] case: PathBuf) -> TestResult {
let test_name = case.file_stem().unwrap().to_str().unwrap().to_string();
let raw_bridge_output = run_bridge_script(&case)?;
let output = BridgeOutput::from_script_output(&raw_bridge_output)?;
let result: Result<SourceInfoV1, BridgeError> = output.try_into();
let Err(err) = result else {
panic!("PKGBUILD to SRCINFO conversion worked, although it should fail.");
};
insta::with_settings!({
description => format!("{test_name} PKGBUILD -> SRCINFO generation."),
snapshot_path => "pkgbuild_invalid_snapshots",
prepend_module_to_snapshot => false,
}, {
assert_snapshot!(format!("{test_name}_srcinfo"), err.to_string());
});
Ok(())
}