MCPcopy Create free account
hub / github.com/archlinux/alpm / ensure_errors_v1

Function ensure_errors_v1

alpm-mtree/tests/interpreter_errors.rs:24–57  ·  view source on GitHub ↗
(#[files("tests/interpreter_error_inputs/*")] case: PathBuf)

Source from the content-addressed store, hash-verified

22/// respective filenames.
23#[rstest]
24fn ensure_errors_v1(#[files("tests/interpreter_error_inputs/*")] case: PathBuf) -> TestResult {
25 // Read the input file and parse it.
26
27 use alpm_common::MetadataFile;
28 use alpm_mtree::Mtree;
29 let input = read_to_string(&case)?;
30 let result = Mtree::from_file_with_schema(
31 &case,
32 Some(alpm_mtree::MtreeSchema::V1(SchemaVersion::new(
33 Version::new(1, 0, 0),
34 ))),
35 );
36
37 let Err(error) = result else {
38 panic!("The interpreter succeeded even though it should've failed for input:\n{input}");
39 };
40
41 let name = case.file_stem().unwrap().to_str().unwrap();
42
43 // Run the tests with the input being displayed as the description.
44 // This makes reviewing this whole stuff a lot easier.
45 // Also remove the usual module prefix, as we're already manually sorting snapshots by test
46 // scenario.
47 let input_clone = input.clone();
48 insta::with_settings!({
49 description => input_clone,
50 snapshot_path => "interpreter_error_snapshots",
51 prepend_module_to_snapshot => false,
52 }, {
53 assert_snapshot!(name, error);
54 });
55
56 Ok(())
57}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected