This is an automated email from the ASF dual-hosted git repository. Kriskras99 pushed a commit to branch chore/dead_code in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit e86070e259f260b42dae8a30ec06a76ea5f55d43 Author: Kriskras99 <[email protected]> AuthorDate: Fri Sep 4 21:44:54 2026 +0200 chore: Remove code that is no longer needed --- avro/tests/schema.rs | 63 +++++++++++++++---------------- avro/tests/to_from_avro_datum_schemata.rs | 8 ++-- avro_test_helper/src/lib.rs | 5 --- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/avro/tests/schema.rs b/avro/tests/schema.rs index 2da2924..81db0d9 100644 --- a/avro/tests/schema.rs +++ b/avro/tests/schema.rs @@ -32,13 +32,12 @@ use apache_avro::{ use apache_avro_test_helper::{ TestResult, data::{DOC_EXAMPLES, OTHER_ATTRIBUTES_EXAMPLES, examples, valid_examples}, - init, }; use serde::{Deserialize, Serialize}; #[test] fn test_correct_recursive_extraction() -> TestResult { - init(); + let raw_outer_schema = r#"{ "type": "record", "name": "X", @@ -89,7 +88,7 @@ fn test_correct_recursive_extraction() -> TestResult { #[test] fn test_parse() -> TestResult { - init(); + for (raw_schema, valid) in examples().iter() { let schema = Schema::parse_str(raw_schema); if *valid { @@ -109,7 +108,7 @@ fn test_parse() -> TestResult { #[test] fn test_3799_parse_reader() -> TestResult { - init(); + for (raw_schema, valid) in examples().iter() { let schema = Schema::parse_reader(&mut Cursor::new(raw_schema)); if *valid { @@ -167,7 +166,7 @@ fn test_3799_raise_io_error_from_parse_read() -> Result<(), String> { #[test] /// Test that the string generated by an Avro Schema object is, in fact, a valid Avro schema. fn test_valid_cast_to_string_after_parse() -> TestResult { - init(); + for (raw_schema, _) in valid_examples().iter() { let schema = Schema::parse_str(raw_schema)?; Schema::parse_str(schema.canonical_form().as_str())?; @@ -179,7 +178,7 @@ fn test_valid_cast_to_string_after_parse() -> TestResult { /// Test that a list of schemas whose definitions do not depend on each other produces the same /// result as parsing each element of the list individually fn test_parse_list_without_cross_deps() -> TestResult { - init(); + let schema_str_1 = r#"{ "name": "A", "type": "record", @@ -208,7 +207,7 @@ fn test_parse_list_without_cross_deps() -> TestResult { /// the schemas are input. /// However, the output order is guaranteed to be the same as the input order. fn test_parse_list_with_cross_deps_basic() -> TestResult { - init(); + let schema_a_str = r#"{ "name": "A", "type": "record", @@ -236,7 +235,7 @@ fn test_parse_list_with_cross_deps_basic() -> TestResult { #[test] fn test_parse_list_recursive_type() -> TestResult { - init(); + let schema_str_1 = r#"{ "name": "A", "doc": "A's schema", @@ -263,7 +262,7 @@ fn test_parse_list_recursive_type() -> TestResult { #[test] /// Test that schema composition resolves namespaces. fn test_parse_list_with_cross_deps_and_namespaces() -> TestResult { - init(); + let schema_a_str = r#"{ "name": "A", "type": "record", @@ -292,7 +291,7 @@ fn test_parse_list_with_cross_deps_and_namespaces() -> TestResult { #[test] /// Test that schema composition fails on namespace errors. fn test_parse_list_with_cross_deps_and_namespaces_error() -> TestResult { - init(); + let schema_str_1 = r#"{ "name": "A", "type": "record", @@ -321,7 +320,7 @@ fn test_parse_list_with_cross_deps_and_namespaces_error() -> TestResult { // <https://issues.apache.org/jira/browse/AVRO-3216> // test that field's RecordSchema could be referenced by a following field by full name fn test_parse_reused_record_schema_by_fullname() -> TestResult { - init(); + let schema_str = r#" { "type" : "record", @@ -436,7 +435,7 @@ fn permutation_indices(indices: Vec<usize>) -> Vec<Vec<usize>> { /// Test that a type that depends on more than one other type is parsed correctly when all /// definitions are passed in as a list. This should work regardless of the ordering of the list. fn test_parse_list_multiple_dependencies() -> TestResult { - init(); + let schema_a_str = r#"{ "name": "A", "type": "record", @@ -474,7 +473,7 @@ fn test_parse_list_multiple_dependencies() -> TestResult { /// Test that a type that is depended on by more than one other type is parsed correctly when all /// definitions are passed in as a list. This should work regardless of the ordering of the list. fn test_parse_list_shared_dependency() -> TestResult { - init(); + let schema_a_str = r#"{ "name": "A", "type": "record", @@ -513,7 +512,7 @@ fn test_parse_list_shared_dependency() -> TestResult { #[test] /// Test that trying to parse two schemas with the same fullname returns an Error fn test_name_collision_error() -> TestResult { - init(); + let schema_str_1 = r#"{ "name": "foo.A", "type": "record", @@ -537,7 +536,7 @@ fn test_name_collision_error() -> TestResult { #[test] /// Test that having the same name but different fullnames does not return an error fn test_namespace_prevents_collisions() -> TestResult { - init(); + let schema_str_1 = r#"{ "name": "A", "type": "record", @@ -588,7 +587,7 @@ fn test_namespace_prevents_collisions() -> TestResult { #[test] fn test_fullname_name_and_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a", "namespace": "o.a.h", "aliases": null}"#)?; let fullname = name.fullname(None); @@ -598,7 +597,7 @@ fn test_fullname_name_and_namespace_specified() -> TestResult { #[test] fn test_fullname_fullname_and_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a.b.c.d", "namespace": "o.a.h"}"#)?; assert_eq!(name.name(), "d"); assert_eq!(name.namespace(), Some("a.b.c")); @@ -609,7 +608,7 @@ fn test_fullname_fullname_and_namespace_specified() -> TestResult { #[test] fn test_fullname_name_and_default_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a", "namespace": null}"#)?; assert_eq!(name.name(), "a"); assert_eq!(name.namespace(), None); @@ -620,7 +619,7 @@ fn test_fullname_name_and_default_namespace_specified() -> TestResult { #[test] fn test_fullname_fullname_and_default_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a.b.c.d", "namespace": null}"#)?; assert_eq!(name.name(), "d"); assert_eq!(name.namespace(), Some("a.b.c")); @@ -631,7 +630,7 @@ fn test_fullname_fullname_and_default_namespace_specified() -> TestResult { #[test] fn test_avro_3452_parsing_name_without_namespace() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a.b.c.d"}"#)?; assert_eq!(name.name(), "d"); assert_eq!(name.namespace(), Some("a.b.c")); @@ -642,7 +641,7 @@ fn test_avro_3452_parsing_name_without_namespace() -> TestResult { #[test] fn test_avro_3452_parsing_name_with_leading_dot_without_namespace() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": ".a"}"#)?; assert_eq!(name.name(), "a"); assert_eq!(name.namespace(), None); @@ -652,7 +651,7 @@ fn test_avro_3452_parsing_name_with_leading_dot_without_namespace() -> TestResul #[test] fn test_avro_3452_parse_json_without_name_field() -> TestResult { - init(); + let result: serde_json::error::Result<Name> = serde_json::from_str(r#"{"unknown": "a"}"#); assert!(&result.is_err()); assert_eq!(result.unwrap_err().to_string(), "No `name` field"); @@ -661,7 +660,7 @@ fn test_avro_3452_parse_json_without_name_field() -> TestResult { #[test] fn test_fullname_fullname_namespace_and_default_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a.b.c.d", "namespace": "o.a.a", "aliases": null}"#)?; assert_eq!(name.name(), "d"); @@ -673,7 +672,7 @@ fn test_fullname_fullname_namespace_and_default_namespace_specified() -> TestRes #[test] fn test_fullname_name_namespace_and_default_namespace_specified() -> TestResult { - init(); + let name: Name = serde_json::from_str(r#"{"name": "a", "namespace": "o.a.a", "aliases": null}"#)?; assert_eq!(name.name(), "a"); @@ -685,7 +684,7 @@ fn test_fullname_name_namespace_and_default_namespace_specified() -> TestResult #[test] fn test_doc_attributes() -> TestResult { - init(); + fn assert_doc(schema: &Schema) { match schema { Schema::Enum(EnumSchema { doc, .. }) => assert!(doc.is_some()), @@ -746,7 +745,7 @@ fn test_avro_old_93_other_attributes() -> TestResult { #[test] fn test_root_error_is_not_swallowed_on_parse_error() -> Result<(), String> { - init(); + let raw_schema = "/not/a/real/file"; let error = Schema::parse_str(raw_schema).unwrap_err().into_details(); @@ -765,7 +764,7 @@ fn test_root_error_is_not_swallowed_on_parse_error() -> Result<(), String> { // AVRO-3302 #[test] fn test_record_schema_with_cyclic_references() -> TestResult { - init(); + let schema = Schema::parse_str( r#" { @@ -833,7 +832,7 @@ fn test_record_schema_with_cyclic_references() -> TestResult { // https://github.com/flavray/avro-rs/issues/47 #[test] fn avro_old_issue_47() -> TestResult { - init(); + let schema_str = r#" { "type": "record", @@ -2052,7 +2051,7 @@ fn test_avro_3851_read_default_value_for_enum() -> TestResult { #[test] fn avro_rs_66_test_independent_canonical_form_primitives() -> TestResult { - init(); + let record_primitive = r#"{ "name": "Rec", "namespace": "ns", @@ -2153,7 +2152,7 @@ fn avro_rs_66_test_independent_canonical_form_primitives() -> TestResult { #[test] fn avro_rs_66_test_independent_canonical_form_usages() -> TestResult { - init(); + let record_primitive = r#"{ "name": "Rec", "namespace": "ns", @@ -2291,7 +2290,7 @@ fn avro_rs_66_test_independent_canonical_form_usages() -> TestResult { #[test] fn avro_rs_66_test_independent_canonical_form_deep_recursion() -> TestResult { - init(); + let record_primitive = r#"{ "name": "Rec", "namespace": "ns", @@ -2359,7 +2358,7 @@ fn avro_rs_66_test_independent_canonical_form_deep_recursion() -> TestResult { #[test] fn avro_rs_66_test_independent_canonical_form_missing_ref() -> TestResult { - init(); + let record_primitive = r#"{ "name": "Rec", "namespace": "ns", diff --git a/avro/tests/to_from_avro_datum_schemata.rs b/avro/tests/to_from_avro_datum_schemata.rs index 0849367..734ce7b 100644 --- a/avro/tests/to_from_avro_datum_schemata.rs +++ b/avro/tests/to_from_avro_datum_schemata.rs @@ -18,7 +18,7 @@ use apache_avro::reader::datum::GenericDatumReader; use apache_avro::writer::datum::GenericDatumWriter; use apache_avro::{Codec, Reader, Schema, Writer, types::Value}; -use apache_avro_test_helper::{TestResult, init}; +use apache_avro_test_helper::{TestResult}; static SCHEMA_A_STR: &str = r#"{ "name": "A", @@ -38,7 +38,7 @@ static SCHEMA_B_STR: &str = r#"{ #[test] fn test_avro_3683_multiple_schemata_to_from_avro_datum() -> TestResult { - init(); + let record: Value = Value::Record(vec![( String::from("field_b"), @@ -68,7 +68,7 @@ fn test_avro_3683_multiple_schemata_to_from_avro_datum() -> TestResult { #[test] fn avro_rs_106_test_multiple_schemata_to_from_avro_datum_with_resolution() -> TestResult { - init(); + let record: Value = Value::Record(vec![( String::from("field_b"), @@ -100,7 +100,7 @@ fn avro_rs_106_test_multiple_schemata_to_from_avro_datum_with_resolution() -> Te #[test] fn test_avro_3683_multiple_schemata_writer_reader() -> TestResult { - init(); + let record: Value = Value::Record(vec![( String::from("field_b"), diff --git a/avro_test_helper/src/lib.rs b/avro_test_helper/src/lib.rs index 28c017d..7c752b5 100644 --- a/avro_test_helper/src/lib.rs +++ b/avro_test_helper/src/lib.rs @@ -62,8 +62,3 @@ impl<Err: Display + Debug> From<Err> for TestError { } pub type TestResult = Result<(), TestError>; - -/// Does nothing. Just loads the crate. -/// Should be used in the integration tests, because they do not use [dev-dependencies] -/// and do not auto-load this crate. -pub const fn init() {}
