Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Nov 18, 2021
1 parent c92dae5 commit 64965b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/it/io/avro/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Read and write from and to Apache Avro
mod read;
#[cfg(feature = "io_avro_async")]
mod read_async;
2 changes: 1 addition & 1 deletion tests/it/io/avro/read/mod.rs → tests/it/io/avro/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn schema() -> (AvroSchema, Schema) {
(AvroSchema::parse_str(raw_schema).unwrap(), schema)
}

fn write(codec: Codec) -> Result<(Vec<u8>, RecordBatch)> {
pub(super) fn write(codec: Codec) -> Result<(Vec<u8>, RecordBatch)> {
let (avro, schema) = schema();
// a writer needs a schema and something to write to
let mut writer = Writer::with_codec(&avro, Vec::new(), codec);
Expand Down
23 changes: 23 additions & 0 deletions tests/it/io/avro/read_async.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use avro_rs::Codec;

use arrow2::error::Result;
use arrow2::io::avro::read;

use super::read::write;

async fn _test_metadata(codec: Codec) -> Result<()> {
let (data, expected) = write(codec).unwrap();

let file = &mut &data[..];

let (_, schema, _, _) = read::read_metadata(file)?;

assert_eq!(&schema, expected.schema().as_ref());

Ok(())
}

#[tokio::test]
async fn read_metadata() -> Result<()> {
_test_metadata(Codec::Null).await
}

0 comments on commit 64965b6

Please sign in to comment.