Kriskras99 commented on code in PR #395:
URL: https://github.com/apache/avro-rs/pull/395#discussion_r2679396622


##########
avro/src/schema.rs:
##########
@@ -7551,4 +7551,75 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_duration() -> TestResult {
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "duration",
+            "name": "Duration",
+            "size": 12
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),

Review Comment:
   ```suggestion
   
           assert_eq!(
               schema_json_str.matches("logicalType").count(),
   ```



##########
avro/src/schema.rs:
##########
@@ -7551,4 +7551,75 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_duration() -> TestResult {
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "duration",
+            "name": "Duration",
+            "size": 12
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),
+            1,
+            "Expected serialized schema to contain only one logicalType key: 
{schema_json_str}"
+        );
+
+        Ok(())
+    }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_uuid_fixed() -> TestResult {
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "uuid",
+            "name": "UUID",
+            "size": 16
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),

Review Comment:
   ```suggestion
   
           assert_eq!(
               schema_json_str.matches("logicalType").count(),
   ```



##########
avro/src/schema.rs:
##########
@@ -7551,4 +7551,75 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_duration() -> TestResult {
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "duration",
+            "name": "Duration",
+            "size": 12
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),
+            1,
+            "Expected serialized schema to contain only one logicalType key: 
{schema_json_str}"
+        );
+
+        Ok(())
+    }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_uuid_fixed() -> TestResult {
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "uuid",
+            "name": "UUID",
+            "size": 16
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),
+            1,
+            "Expected serialized schema to contain only one logicalType key: 
{schema_json_str}"
+        );
+
+        Ok(())
+    }
+
+    #[test]
+    fn avro_rs_395_logical_type_written_once_for_decimal_fixed() -> TestResult 
{
+        let schema = Schema::parse_str(
+            r#"{
+            "type": "fixed",
+            "logicalType": "decimal",
+            "scale": 4,
+            "precision": 8,
+            "name": "FixedDecimal16",
+            "size": 16
+        }"#,
+        )?;
+
+        let schema_json_str = serde_json::to_string(&schema)?;
+        let logical_type_keys: Vec<&str> = 
schema_json_str.matches("logicalType").collect();
+
+        assert_eq!(
+            logical_type_keys.len(),

Review Comment:
   ```suggestion
   
           assert_eq!(
               schema_json_str.matches("logicalType").count(),
   ```



-- 
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]

Reply via email to