mirror of
https://codeberg.org/icewind/vmt-parser.git
synced 2026-08-02 12:24:46 +02:00
patch resolving
This commit is contained in:
parent
b6a7ee888b
commit
1e1733f5f7
7 changed files with 106 additions and 13 deletions
|
|
@ -1,7 +1,17 @@
|
|||
use miette::{GraphicalReportHandler, GraphicalTheme};
|
||||
use std::fs::read_to_string;
|
||||
use test_case::test_case;
|
||||
use thiserror::Error;
|
||||
use vmt_parser::from_str;
|
||||
use vmt_parser::material::Material;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum LoaderError {
|
||||
#[error(transparent)]
|
||||
Io(#[from] std::io::Error),
|
||||
#[error(transparent)]
|
||||
Vdf(#[from] vdf_reader::VdfError),
|
||||
}
|
||||
|
||||
#[test_case("tests/data/concretefloor003.vmt")]
|
||||
#[test_case("tests/data/mvm_backpack.vmt")]
|
||||
|
|
@ -11,7 +21,15 @@ use vmt_parser::from_str;
|
|||
fn test_serde(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str(&raw) {
|
||||
Ok(result) => insta::assert_ron_snapshot!(path, result),
|
||||
Ok(result) => {
|
||||
insta::assert_ron_snapshot!(path, result);
|
||||
if let Material::Patch(patch) = result {
|
||||
let patched = patch
|
||||
.resolve(|path| read_to_string(path).map_err(LoaderError::from))
|
||||
.unwrap();
|
||||
insta::assert_ron_snapshot!(format!("{}_resolved", path), patched);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
|
||||
let mut out = String::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue