mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
fix(anicraft): preserve invalid envelope diagnostic
This commit is contained in:
1 parent
9a2dafbf7d
commit
0b1688098a
1 file changed
+9
-1
@@ -105,7 +105,7 @@ where
|
||||
type Value = Envelope<D::Document>;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str("an AniCraft native project envelope")
|
||||
formatter.write_str("an .anicraft envelope object")
|
||||
}
|
||||
|
||||
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
|
||||
@@ -240,6 +240,14 @@ mod tests {
|
||||
assert_eq!(decoder.calls, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_top_level_keeps_the_native_envelope_diagnostic() {
|
||||
let mut decoder = CaptureDocument::default();
|
||||
let error = read::<String, _>("[]", &mut decoder).unwrap_err();
|
||||
assert!(error.to_string().contains("expected an .anicraft envelope object"));
|
||||
assert_eq!(decoder.calls, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_documents_use_the_last_successful_value() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let json = r#"{"format":"anicraft","version":1,"document":{"value":1},"document":{"value":2}}"#;
|
||||
|
||||
Reference in new issue
Block a user