You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/04/18 19:44:03 UTC

[avro] branch master updated: AVRO-3494: Uncomment a test for recursive types (#1648)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5bdebfdc5 AVRO-3494: Uncomment a test for recursive types (#1648)
5bdebfdc5 is described below

commit 5bdebfdc53f1c0ff62af9f84942f2519946fa3fb
Author: Martin Grigorov <ma...@users.noreply.github.com>
AuthorDate: Mon Apr 18 22:43:57 2022 +0300

    AVRO-3494: Uncomment a test for recursive types (#1648)
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 lang/rust/avro/tests/schema.rs | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/lang/rust/avro/tests/schema.rs b/lang/rust/avro/tests/schema.rs
index 1410424ba..f58b62f9e 100644
--- a/lang/rust/avro/tests/schema.rs
+++ b/lang/rust/avro/tests/schema.rs
@@ -565,12 +565,6 @@ lazy_static! {
         EXAMPLES.iter().copied().filter(|s| s.1).collect();
 }
 
-/*
-// TODO: (#92) properly support recursive types and uncomment
-
-This test is failing unwrapping the outer schema with ParseSchemaError("Unknown type: X"). It seems
-that recursive types are not properly supported.
-
 #[test]
 fn test_correct_recursive_extraction() {
     init();
@@ -594,21 +588,31 @@ fn test_correct_recursive_extraction() {
         ]
     }"#;
     let outer_schema = Schema::parse_str(raw_outer_schema).unwrap();
-    if let Schema::Record { fields: outer_fields, .. } = outer_schema {
-        let raw_inner_schema = outer_fields[0].schema.canonical_form();
-        let inner_schema = Schema::parse_str(raw_inner_schema.as_str()).unwrap();
-        if let Schema::Record { fields: inner_fields, .. } = inner_schema {
-            if let Schema::Record {name: recursive_type, .. } = &inner_fields[0].schema {
+    if let Schema::Record {
+        fields: outer_fields,
+        ..
+    } = outer_schema
+    {
+        let inner_schema = &outer_fields[0].schema;
+        if let Schema::Record {
+            fields: inner_fields,
+            ..
+        } = inner_schema
+        {
+            if let Schema::Record {
+                name: recursive_type,
+                ..
+            } = &inner_fields[0].schema
+            {
                 assert_eq!("X", recursive_type.name.as_str());
             }
         } else {
-            panic!("inner schema {} should have been a record", raw_inner_schema)
+            panic!("inner schema {:?} should have been a record", inner_schema)
         }
     } else {
-        panic!("outer schema {} should have been a record", raw_outer_schema)
+        panic!("outer schema {:?} should have been a record", outer_schema)
     }
 }
-*/
 
 #[test]
 fn test_parse() {