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 36f34be AVRO-3240: Move the test data in the test method
36f34be is described below
commit 36f34be4ae5a4c8b7a79867d6e082c5f608d5760
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Fri Jan 7 15:50:14 2022 +0200
AVRO-3240: Move the test data in the test method
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
---
lang/rust/src/reader.rs | 57 +++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 28 deletions(-)
diff --git a/lang/rust/src/reader.rs b/lang/rust/src/reader.rs
index ce6a629..5757044 100644
--- a/lang/rust/src/reader.rs
+++ b/lang/rust/src/reader.rs
@@ -343,7 +343,26 @@ mod tests {
6u8, 102u8, 111u8, 111u8, 84u8, 6u8, 98u8, 97u8, 114u8, 94u8, 61u8,
54u8, 221u8, 190u8,
207u8, 108u8, 180u8, 158u8, 57u8, 114u8, 40u8, 173u8, 199u8, 228u8,
239u8,
];
- const TEST_RECORD_SCHEMA_3240: &str = r#"
+
+ #[test]
+ fn test_from_avro_datum() {
+ let schema = Schema::parse_str(SCHEMA).unwrap();
+ let mut encoded: &'static [u8] = &[54, 6, 102, 111, 111];
+
+ let mut record = Record::new(&schema).unwrap();
+ record.put("a", 27i64);
+ record.put("b", "foo");
+ let expected = record.into();
+
+ assert_eq!(
+ from_avro_datum(&schema, &mut encoded, None).unwrap(),
+ expected
+ );
+ }
+
+ #[test]
+ fn test_from_avro_datum_with_union_to_struct() {
+ const TEST_RECORD_SCHEMA_3240: &str = r#"
{
"type": "record",
"name": "test",
@@ -375,34 +394,16 @@ mod tests {
]
}
"#;
- #[derive(Default, Debug, Deserialize, PartialEq)]
- struct TestRecord3240 {
- a: i64,
- b: String,
- a_nullable_array: Option<Vec<String>>,
- // we are missing the 'a_nullable_boolean' field to simulate missing
keys
- // a_nullable_boolean: Option<bool>,
- a_nullable_string: Option<String>,
- }
-
- #[test]
- fn test_from_avro_datum() {
- let schema = Schema::parse_str(SCHEMA).unwrap();
- let mut encoded: &'static [u8] = &[54, 6, 102, 111, 111];
-
- let mut record = Record::new(&schema).unwrap();
- record.put("a", 27i64);
- record.put("b", "foo");
- let expected = record.into();
-
- assert_eq!(
- from_avro_datum(&schema, &mut encoded, None).unwrap(),
- expected
- );
- }
+ #[derive(Default, Debug, Deserialize, PartialEq)]
+ struct TestRecord3240 {
+ a: i64,
+ b: String,
+ a_nullable_array: Option<Vec<String>>,
+ // we are missing the 'a_nullable_boolean' field to simulate
missing keys
+ // a_nullable_boolean: Option<bool>,
+ a_nullable_string: Option<String>,
+ }
- #[test]
- fn test_from_avro_datum_with_union_to_struct() {
let schema = Schema::parse_str(TEST_RECORD_SCHEMA_3240).unwrap();
let mut encoded: &'static [u8] = &[54, 6, 102, 111, 111];