martin-g commented on code in PR #2599:
URL: https://github.com/apache/avro/pull/2599#discussion_r1407749504
##########
lang/rust/avro/src/decimal.rs:
##########
@@ -214,4 +218,63 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn other() -> TestResult {
Review Comment:
Please give the method a better name, e.g. `test_avro_3912_...`
##########
lang/rust/avro/src/decimal.rs:
##########
@@ -214,4 +218,63 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn other() -> TestResult {
+ let schema_str = r#"
+ {
+ "type": "record",
+ "name": "test",
+ "fields": [
+ {
+ "name": "field_name",
+ "type": "bytes",
+ "logicalType": "big-decimal"
+ }
+ ]
+ }
+ "#;
+ let schema = Schema::parse_str(schema_str)?;
+
+ // build record with big decimal value
+ let mut record = Record::new(&schema).unwrap();
+ let val = BigDecimal::new(BigInt::from(12), 2);
+ record.put("field_name", val.clone());
+
+ // save record in writer
+ let codec = Codec::Null;
+ let mut writer = Writer::builder()
+ .schema(&schema)
+ .codec(codec)
+ .writer(Vec::new())
+ .build();
+
+ let result = writer.append(record.clone());
+ assert!(result.is_ok(), "Append KO : {}", result.unwrap_err());
Review Comment:
```suggestion
assert!(result.is_ok(), "Append NOK : {result}");
```
##########
lang/rust/avro/src/decimal.rs:
##########
@@ -214,4 +218,63 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn other() -> TestResult {
+ let schema_str = r#"
+ {
+ "type": "record",
+ "name": "test",
+ "fields": [
+ {
+ "name": "field_name",
+ "type": "bytes",
+ "logicalType": "big-decimal"
+ }
+ ]
+ }
+ "#;
+ let schema = Schema::parse_str(schema_str)?;
+
+ // build record with big decimal value
+ let mut record = Record::new(&schema).unwrap();
+ let val = BigDecimal::new(BigInt::from(12), 2);
+ record.put("field_name", val.clone());
+
+ // save record in writer
Review Comment:
```suggestion
// write a record
```
##########
lang/rust/avro/src/decimal.rs:
##########
@@ -214,4 +218,63 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn other() -> TestResult {
+ let schema_str = r#"
+ {
+ "type": "record",
+ "name": "test",
+ "fields": [
+ {
+ "name": "field_name",
+ "type": "bytes",
+ "logicalType": "big-decimal"
+ }
+ ]
+ }
+ "#;
+ let schema = Schema::parse_str(schema_str)?;
+
+ // build record with big decimal value
+ let mut record = Record::new(&schema).unwrap();
+ let val = BigDecimal::new(BigInt::from(12), 2);
+ record.put("field_name", val.clone());
+
+ // save record in writer
+ let codec = Codec::Null;
+ let mut writer = Writer::builder()
+ .schema(&schema)
+ .codec(codec)
+ .writer(Vec::new())
+ .build();
+
+ let result = writer.append(record.clone());
+ assert!(result.is_ok(), "Append KO : {}", result.unwrap_err());
+ assert!(writer.flush().is_ok(), "Flush KO");
Review Comment:
Actually there is no need to `assert!()` these above. You could just use
`?`, e.g. `writer.append(record.clone())?;` and it will propagate the error
because the method returns `TestResult`.
I try to avoid using `.unwrap()` in general. Especially in non-test code its
usage should be forbidden. I am not sure whether there is a Clippy check that
we could enforce.
--
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]