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


##########
avro_derive/tests/derive.rs:
##########
@@ -209,6 +209,41 @@ mod test_derive {
         }
     }
 
+    #[test]
+    fn test_named_record() {
+        #[derive(Debug, Serialize, Deserialize, AvroSchema, Clone, PartialEq, 
Eq)]
+        #[avro(name = "Other", namespace = "com.testing.namespace")]
+        struct TestNamedRecord {
+            a: i32,
+            b: String,
+        }
+
+        let schema = r#"
+        {
+            "type":"record",
+            "name":"com.testing.namespace.Other",
+            "fields":[
+                {
+                    "name":"a",
+                    "type":"int"
+                },
+                {
+                    "name":"b",
+                    "type":"string"
+                }
+            ]
+        }
+        "#;
+        let schema = Schema::parse_str(schema).unwrap();
+        assert_eq!(schema, TestNamedRecord::get_schema());
+        if let Schema::Record(RecordSchema { name, .. }) = 
TestNamedRecord::get_schema() {
+            assert_eq!("Other".to_owned(), name.name);
+            assert_eq!("com.testing.namespace".to_owned(), 
name.namespace.unwrap())

Review Comment:
   ```suggestion
               assert_eq!("Other", name.name.as_str());
               assert_eq!("com.testing.namespace", 
name.namespace.unwrap().as_str())
   ```
   This is slightly nicer in my opinion



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