fix(anicraft): preserve invalid envelope diagnostic

This commit is contained in:
Dylan M. Taylor committed 2026-11-14 03:12:01 +00:00
1 parent 9a2dafbf7d
commit 0b1688098a
1 file changed
+9 -1
+9 -1
View File
@@ -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}}"#;