Skip to content

Commit

Permalink
chore: use snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
allevo committed Jan 9, 2025
1 parent e9d1a86 commit 330a815
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tests/testsuite/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,15 @@ fn test_json_error_with_path() {
.build()
.unwrap();

match c.try_deserialize_with_error_path::<Settings>() {
Ok(_) => panic!("expected a type error"),
Err(err) => {
let path = err.path().to_string();
assert_eq!(path, "inner.value");

let s = format!("{err}");
assert_eq!(
s,
"inner.value: invalid type: unit value, expected a string for key `inner.value`"
);
}
}
let without_path = c.clone().try_deserialize::<Settings>();
assert_data_eq!(
without_path.unwrap_err().to_string(),
str!["invalid type: unit value, expected a string for key `inner.value`"]
);

let with_path = c.try_deserialize_with_error_path::<Settings>();
assert_data_eq!(
with_path.unwrap_err().to_string(),
str!["inner.value: invalid type: unit value, expected a string for key `inner.value`"]
);
}

0 comments on commit 330a815

Please sign in to comment.