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 13625ab  test: uncomment attribute test and delete commented outdated 
test (#362)
13625ab is described below

commit 13625abd7d08caa2eff8535768d5547b21f4bdff
Author: Kriskras99 <[email protected]>
AuthorDate: Wed Dec 10 10:14:45 2025 +0100

    test: uncomment attribute test and delete commented outdated test (#362)
    
    Co-authored-by: default <[email protected]>
---
 avro/tests/schema.rs         | 62 +++++++++++++++++---------------------------
 avro_test_helper/src/data.rs |  5 ++--
 2 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/avro/tests/schema.rs b/avro/tests/schema.rs
index be89102..e986848 100644
--- a/avro/tests/schema.rs
+++ b/avro/tests/schema.rs
@@ -30,7 +30,7 @@ use apache_avro::{
 };
 use apache_avro_test_helper::{
     TestResult,
-    data::{DOC_EXAMPLES, examples, valid_examples},
+    data::{DOC_EXAMPLES, OTHER_ATTRIBUTES_EXAMPLES, examples, valid_examples},
     init,
 };
 
@@ -708,39 +708,41 @@ fn test_doc_attributes() -> TestResult {
     Ok(())
 }
 
-/*
-TODO: (#94) add support for user-defined attributes and uncomment (may need 
some tweaks to compile)
+// https://github.com/flavray/avro-rs/issues/93
 #[test]
-fn test_other_attributes() {
-    fn assert_attribute_type(attribute: (String, serde_json::Value)) {
-        match attribute.1.as_ref() {
-            "cp_boolean" => assert!(attribute.2.is_bool()),
-            "cp_int" => assert!(attribute.2.is_i64()),
-            "cp_object" => assert!(attribute.2.is_object()),
-            "cp_float" => assert!(attribute.2.is_f64()),
-            "cp_array" => assert!(attribute.2.is_array()),
+fn test_avro_old_93_other_attributes() -> TestResult {
+    fn assert_attribute_type(attribute: (&String, &serde_json::Value)) {
+        match attribute.0.as_str() {
+            "cp_boolean" => assert!(attribute.1.is_boolean()),
+            "cp_int" => assert!(attribute.1.is_i64()),
+            "cp_object" => assert!(attribute.1.is_object()),
+            "cp_float" => assert!(attribute.1.is_f64()),
+            "cp_array" => assert!(attribute.1.is_array()),
+            "cp_string" => assert!(attribute.1.is_string()),
+            "cp_null" => assert!(attribute.1.is_null()),
+            _ => panic!("Unexpected attribute name: {attribute:?}"),
         }
     }
 
     for (raw_schema, _) in OTHER_ATTRIBUTES_EXAMPLES.iter() {
         let schema = Schema::parse_str(raw_schema)?;
         // all inputs have at least some user-defined attributes
-        assert!(schema.other_attributes.is_some());
-        for prop in schema.other_attributes?.iter() {
+        assert!(schema.custom_attributes().is_some());
+        for prop in schema.custom_attributes().unwrap().iter() {
             assert_attribute_type(prop);
         }
-        if let Schema::Record { fields, .. } = schema {
-           for f in fields {
-               // all fields in the record have at least some user-defined 
attributes
-               assert!(f.schema.other_attributes.is_some());
-               for prop in f.schema.other_attributes?.iter() {
-                   assert_attribute_type(prop);
-               }
-           }
+        if let Schema::Record(RecordSchema { fields, .. }) = schema {
+            for f in fields {
+                // all fields in the record have at least some user-defined 
attributes
+                assert!(!f.custom_attributes.is_empty());
+                for prop in f.custom_attributes.iter() {
+                    assert_attribute_type(prop);
+                }
+            }
         }
     }
+    Ok(())
 }
-*/
 
 #[test]
 fn test_root_error_is_not_swallowed_on_parse_error() -> Result<(), String> {
@@ -828,22 +830,6 @@ fn test_record_schema_with_cyclic_references() -> 
TestResult {
     Ok(())
 }
 
-/*
-// TODO: (#93) add support for logical type and attributes and uncomment (may 
need some tweaks to compile)
-#[test]
-fn test_decimal_valid_type_attributes() {
-    init();
-    let fixed_decimal = Schema::parse_str(DECIMAL_LOGICAL_TYPE_ATTRIBUTES[0])?;
-    assert_eq!(4, fixed_decimal.get_attribute("precision"));
-    assert_eq!(2, fixed_decimal.get_attribute("scale"));
-    assert_eq!(2, fixed_decimal.get_attribute("size"));
-
-    let bytes_decimal = Schema::parse_str(DECIMAL_LOGICAL_TYPE_ATTRIBUTES[1])?;
-    assert_eq!(4, bytes_decimal.get_attribute("precision"));
-    assert_eq!(0, bytes_decimal.get_attribute("scale"));
-}
-*/
-
 // https://github.com/flavray/avro-rs/issues/47
 #[test]
 fn avro_old_issue_47() -> TestResult {
diff --git a/avro_test_helper/src/data.rs b/avro_test_helper/src/data.rs
index 662df23..8f61777 100644
--- a/avro_test_helper/src/data.rs
+++ b/avro_test_helper/src/data.rs
@@ -362,8 +362,8 @@ pub const OTHER_ATTRIBUTES_EXAMPLES: &[(&str, bool)] = &[
                 "cp_int": 1,
                 "cp_array": [ 1, 2, 3, 4],
                 "fields": [
-                    {"name": "f1", "type": "string", "cp_object": 
{"a":1,"b":2}},
-                    {"name": "f2", "type": "long", "cp_null": null}
+                    {"name": "f1", "type": "fixed", "size": 16, "cp_object": 
{"a":1,"b":2}},
+                    {"name": "f2", "type": "fixed", "size": 8, "cp_null": null}
                 ]
             }"#,
         true,
@@ -381,7 +381,6 @@ pub const OTHER_ATTRIBUTES_EXAMPLES: &[(&str, bool)] = &[
             }"#,
         true,
     ),
-    (r#"{"type": "long", "date": "true"}"#, true),
 ];
 
 pub const DECIMAL_LOGICAL_TYPE: &[(&str, bool)] = &[

Reply via email to