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

Function ensure_errors_v1

alpm-mtree/tests/parse_errors.rs:22–47  ·  view source on GitHub ↗
(#[files("tests/parse_error_inputs/*")] case: PathBuf)

Source from the content-addressed store, hash-verified

20/// respective name of the input file.
21#[rstest]
22fn ensure_errors_v1(#[files("tests/parse_error_inputs/*")] case: PathBuf) -> TestResult {
23 // Read the input file and parse it.
24 let input = read_to_string(&case)?;
25 let result = mtree.parse(input.as_str());
26
27 let Err(error) = result else {
28 panic!("The parser succeeded even though it should've failed for input:\n{input}");
29 };
30
31 let name = case.file_stem().unwrap().to_str().unwrap();
32
33 // Run the tests with the input being displayed as the description.
34 // This makes reviewing this whole stuff a lot easier.
35 // Also remove the usual module prefix by explicitly setting the snapshot path.
36 // This isn't necessary, as we're already manually sorting snapshots by test scenario.
37 let input_clone = input.clone();
38 insta::with_settings!({
39 description => input_clone,
40 snapshot_path => "parse_error_snapshots",
41 prepend_module_to_snapshot => false,
42 }, {
43 assert_snapshot!(name, error);
44 });
45
46 Ok(())
47}

Callers

nothing calls this directly

Calls 2

parseMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected