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

mgrigorov pushed a commit to branch avro-rs-53-uuid-with-fixed
in repository https://gitbox.apache.org/repos/asf/avro-rs.git

commit 4877c8932dbe5b09d3877d6102af8f05498cb0a8
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Tue Nov 19 11:36:43 2024 +0200

    Issue #53: Add the test to the suite to prevent regressions
    
    Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
---
 avro/src/schema.rs | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/avro/src/schema.rs b/avro/src/schema.rs
index 177cc3e..dfd94e5 100644
--- a/avro/src/schema.rs
+++ b/avro/src/schema.rs
@@ -2509,7 +2509,7 @@ pub mod derive {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::rabin::Rabin;
+    use crate::{rabin::Rabin, SpecificSingleObjectWriter};
     use apache_avro_test_helper::{
         logger::{assert_logged, assert_not_logged},
         TestResult,
@@ -6443,6 +6443,44 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn avro_rs_53_uuid_with_fixed() -> TestResult {
+        #[derive(Debug, Serialize, Deserialize)]
+        struct Comment {
+            id: crate::Uuid,
+        }
+
+        impl AvroSchema for Comment {
+            fn get_schema() -> Schema {
+                Schema::parse_str(
+                    r#"{
+                "type" : "record",
+                "name" : "Comment",
+                "fields" : [ {
+                  "name" : "id",
+                  "type" : {
+                    "type" : "fixed",
+                    "size" : 16,
+                    "logicalType" : "uuid",
+                    "name": "FixedUUID"
+                  }
+                } ]
+             }"#,
+                )
+                .expect("Invalid Comment Avro schema")
+            }
+        }
+
+        let payload = Comment {
+            id: "de2df598-9948-4988-b00a-a41c0e287398".parse().unwrap(),
+        };
+        let mut buffer = Vec::new();
+        SpecificSingleObjectWriter::<Comment>::with_capacity(10)?
+            .write_ref(&payload, &mut buffer)?;
+
+        Ok(())
+    }
+
     #[test]
     fn avro_3926_uuid_schema_for_fixed_with_size_16() -> TestResult {
         let schema = json!(

Reply via email to