Kriskras99 commented on code in PR #351:
URL: https://github.com/apache/avro-rs/pull/351#discussion_r2597470625
##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn
avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
},
)
}
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+ #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+ struct T {
+ x: Option<i8>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ y: Option<String>,
+ z: Option<i8>,
+ }
+
+ ser_deser::<T>(
+ &T::get_schema(),
+ T {
+ x: None,
+ y: None,
+ z: Some(1),
+ },
+ )
+ .unwrap()
Review Comment:
That doesn't work. `ser_deser` is supposed to error and because creating a
TestResult is the same as panicking I need to check the panic message.
If I add a `-> TestResult` and return `Ok(())` clippy complains that my
should_panic test should not have a return type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]