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

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


The following commit(s) were added to refs/heads/main by this push:
     new 02c8dbe  Issue #53: Add the test to the suite to prevent regressions 
(#55)
02c8dbe is described below

commit 02c8dbeab9a254cdd1d94aad71f7ee4647d32994
Author: Martin Grigorov <[email protected]>
AuthorDate: Thu Nov 21 09:20:10 2024 +0200

    Issue #53: Add the test to the suite to prevent regressions (#55)
    
    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..343af0a 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()?,
+        };
+        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