martin-g commented on code in PR #1850:
URL: https://github.com/apache/avro/pull/1850#discussion_r1061314968


##########
lang/rust/avro/tests/shared.rs:
##########
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use apache_avro::{types::Value, Codec, Reader, Schema, Writer};
+use std::{
+    fs::{DirEntry, File, ReadDir},
+    io::{BufReader, Error},
+    path::Path,
+    slice::Iter,
+};
+
+const ROOT_DIRECTORY: &str = "../../../share/test/data/schemas";
+
+#[test]
+fn test_schema() {
+    let directory: ReadDir = scan_shared_folder();
+    directory.for_each(|f: Result<DirEntry, Error>| {
+        let e: DirEntry = match f {
+            Err(error) => panic!("Can't get file {:?}", error),
+            Ok(entry) => entry,
+        };
+        log::warn!("{:?}", e.file_name());
+        let sub_folder = ROOT_DIRECTORY.to_owned() + "/" + 
e.file_name().to_str().unwrap();
+
+        test_folder(sub_folder.as_str());
+    });
+}
+
+fn test_folder(folder: &str) {
+    let file_name = folder.to_owned() + "/schema.json";
+    let content = std::fs::read_to_string(file_name).expect("Unable to find 
schema.jon file");

Review Comment:
   I think it would be better if `test_folder()` returns a `Result<(), Error>`. 
This way all `expect()` calls could be simplified to `?` and we could see the 
real error when it happens.



##########
lang/rust/avro/tests/shared.rs:
##########
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use apache_avro::{types::Value, Codec, Reader, Schema, Writer};
+use std::{
+    fs::{DirEntry, File, ReadDir},
+    io::{BufReader, Error},
+    path::Path,
+    slice::Iter,
+};
+
+const ROOT_DIRECTORY: &str = "../../../share/test/data/schemas";
+
+#[test]
+fn test_schema() {
+    let directory: ReadDir = scan_shared_folder();
+    directory.for_each(|f: Result<DirEntry, Error>| {
+        let e: DirEntry = match f {
+            Err(error) => panic!("Can't get file {:?}", error),
+            Ok(entry) => entry,
+        };
+        log::warn!("{:?}", e.file_name());
+        let sub_folder = ROOT_DIRECTORY.to_owned() + "/" + 
e.file_name().to_str().unwrap();
+
+        test_folder(sub_folder.as_str());
+    });
+}
+
+fn test_folder(folder: &str) {
+    let file_name = folder.to_owned() + "/schema.json";
+    let content = std::fs::read_to_string(file_name).expect("Unable to find 
schema.jon file");
+
+    let schema: Schema = Schema::parse_str(content.as_str()).expect("Can't 
read schema");
+
+    let data_file_name = folder.to_owned() + "/data.avro";
+    let data_path: &Path = Path::new(data_file_name.as_str());
+    if !data_path.exists() {
+        log::warn!("data file does not exist");

Review Comment:
   error!()



##########
lang/rust/avro/tests/shared.rs:
##########
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use apache_avro::{types::Value, Codec, Reader, Schema, Writer};
+use std::{
+    fs::{DirEntry, File, ReadDir},
+    io::{BufReader, Error},
+    path::Path,
+    slice::Iter,
+};
+
+const ROOT_DIRECTORY: &str = "../../../share/test/data/schemas";
+
+#[test]
+fn test_schema() {
+    let directory: ReadDir = scan_shared_folder();
+    directory.for_each(|f: Result<DirEntry, Error>| {
+        let e: DirEntry = match f {
+            Err(error) => panic!("Can't get file {:?}", error),
+            Ok(entry) => entry,
+        };
+        log::warn!("{:?}", e.file_name());

Review Comment:
   debug!() ?



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