You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/10/11 11:12:39 UTC

[avro] 01/01: AVRO-3634: Add a test for deriving a schema for boolean field

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch avro-3634-AvroSchemaComponent-for-bool
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 314af847a74b2248ab45b01d279a896712c772c3
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Tue Oct 11 14:12:15 2022 +0300

    AVRO-3634: Add a test for deriving a schema for boolean field
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 lang/rust/avro_derive/tests/derive.rs | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lang/rust/avro_derive/tests/derive.rs b/lang/rust/avro_derive/tests/derive.rs
index 36b46bd33..76fadcab9 100644
--- a/lang/rust/avro_derive/tests/derive.rs
+++ b/lang/rust/avro_derive/tests/derive.rs
@@ -1040,6 +1040,39 @@ mod test_derive {
         assert_eq!(schema, TestBasicWithLargeDoc::get_schema());
     }
 
+    #[derive(Debug, Serialize, Deserialize, AvroSchema, Clone, PartialEq)]
+    struct TestBasicWithBool {
+        a: bool,
+    }
+
+    proptest! {
+    #[test]
+    fn test_basic_with_bool(a in any::<bool>()) {
+        let schema = r#"
+        {
+            "type":"record",
+            "name":"TestBasicWithBool",
+            "fields":[
+                {
+                    "name":"a",
+                    "type":"boolean"
+                }
+            ]
+        }
+        "#;
+        let schema = Schema::parse_str(schema).unwrap();
+        let derived_schema = TestBasicWithBool::get_schema();
+
+        if let Schema::Record { name, .. } = derived_schema {
+            assert_eq!("TestBasicWithBool", name.fullname(None))
+        } else {
+            panic!("TestBasicWithBool schema must be a record schema")
+        }
+        assert_eq!(schema, TestBasicWithBool::get_schema());
+
+        serde_assert(TestBasicWithBool { a });
+    }}
+
     #[derive(Debug, Serialize, Deserialize, AvroSchema, Clone, PartialEq)]
     struct TestBasicWithU32 {
         a: u32,