Skip to content

Commit 5cefd49

Browse files
committed
All IT tests and examples use sync feature for now
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
1 parent 0ec3a09 commit 5cefd49

16 files changed

+136
-31
lines changed

avro/Cargo.toml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,103 @@ rstest = { default-features = false, version = "0.26.1" }
104104
[package.metadata.docs.rs]
105105
all-features = true
106106
rustdoc-args = ["--cfg", "docsrs"]
107+
108+
[[example]]
109+
name = "benchmark"
110+
path = "examples/benchmark.rs"
111+
required-features = ["sync"]
112+
113+
[[example]]
114+
name = "generate_interop_data"
115+
path = "examples/generate_interop_data.rs"
116+
required-features = ["sync"]
117+
118+
[[example]]
119+
name = "specific_single_object"
120+
path = "examples/specific_single_object.rs"
121+
required-features = ["sync"]
122+
123+
[[example]]
124+
name = "test_interop_data"
125+
path = "examples/test_interop_data.rs"
126+
required-features = ["sync"]
127+
128+
[[example]]
129+
name = "test_interop_single_object_encoding"
130+
path = "examples/test_interop_single_object_encoding.rs"
131+
required-features = ["sync"]
132+
133+
[[example]]
134+
name = "to_value"
135+
path = "examples/to_value.rs"
136+
required-features = ["sync"]
137+
138+
[[test]]
139+
name = "append_to_existing"
140+
path = "tests/append_to_existing.rs"
141+
required-features = ["sync"]
142+
143+
[[test]]
144+
name = "avro-3786"
145+
path = "tests/avro-3786.rs"
146+
required-features = ["sync"]
147+
148+
[[test]]
149+
name = "avro-3787"
150+
path = "tests/avro-3787.rs"
151+
required-features = ["sync"]
152+
153+
[[test]]
154+
name = "avro-rs-219"
155+
path = "tests/avro-rs-219.rs"
156+
required-features = ["sync"]
157+
158+
[[test]]
159+
name = "avro-rs-226"
160+
path = "tests/avro-rs-226.rs"
161+
required-features = ["sync"]
162+
163+
[[test]]
164+
name = "big_decimal"
165+
path = "tests/big_decimal.rs"
166+
required-features = ["sync"]
167+
168+
[[test]]
169+
name = "codecs"
170+
path = "tests/codecs.rs"
171+
required-features = ["sync"]
172+
173+
[[test]]
174+
name = "io"
175+
path = "tests/io.rs"
176+
required-features = ["sync"]
177+
178+
[[test]]
179+
name = "schema"
180+
path = "tests/schema.rs"
181+
required-features = ["sync"]
182+
183+
[[test]]
184+
name = "shared"
185+
path = "tests/shared.rs"
186+
required-features = ["sync"]
187+
188+
[[test]]
189+
name = "to_from_avro_datum_schemata"
190+
path = "tests/to_from_avro_datum_schemata.rs"
191+
required-features = ["sync"]
192+
193+
[[test]]
194+
name = "union_schema"
195+
path = "tests/union_schema.rs"
196+
required-features = ["sync"]
197+
198+
[[test]]
199+
name = "uuids"
200+
path = "tests/uuids.rs"
201+
required-features = ["sync"]
202+
203+
[[test]]
204+
name = "validatrs"
205+
path = "tests/validators.rs"
206+
required-features = ["sync"]

avro/examples/benchmark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
use apache_avro::{
1919
Reader, Writer,
20-
schema::Schema,
21-
types::{Record, Value},
20+
Schema,
21+
types::sync::{Record, Value},
2222
};
2323
use apache_avro_test_helper::TestResult;
2424
use std::{

avro/examples/generate_interop_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
use apache_avro::{
1919
Codec, Writer,
20-
schema::Schema,
21-
types::{Record, Value},
20+
Schema,
21+
types::sync::{Record, Value},
2222
};
2323
use std::{
2424
collections::HashMap,

avro/examples/test_interop_single_object_encoding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use apache_avro::{schema::AvroSchema, types::Value};
18+
use apache_avro::{AvroSchema, types::sync::Value};
1919
use std::error::Error;
2020

2121
struct InteropMessage;

avro/src/bigdecimal.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,17 @@ mod bigdecimal {
106106
use bigdecimal::{One, Zero};
107107
use pretty_assertions::assert_eq;
108108
use std::{
109-
fs::File,
110-
io::BufReader,
111109
ops::{Div, Mul},
112110
str::FromStr,
113111
};
112+
#[synca::cfg(sync)]
113+
use std::fs::File;
114+
#[synca::cfg(tokio)]
115+
use tokio::fs::File;
116+
#[synca::cfg(sync)]
117+
use std::io::BufReader;
118+
#[synca::cfg(tokio)]
119+
use tokio::io::BufReader;
114120

115121
#[tokio::test]
116122
async fn test_avro_3779_bigdecimal_serial() -> TestResult {
@@ -217,8 +223,8 @@ mod bigdecimal {
217223
async fn test_avro_3779_from_java_file() -> TestResult {
218224
// Open file generated with Java code to ensure compatibility
219225
// with Java big decimal logical type.
220-
let file: File = File::open("./tests/bigdec.avro")?;
221-
let mut reader = Reader::new(BufReader::new(&file)).await?;
226+
let file = File::open("./tests/bigdec.avro").await?;
227+
let mut reader = Reader::new(BufReader::new(file)).await?;
222228
let next_element = reader.next().await;
223229
assert!(next_element.is_some());
224230
let value = next_element.unwrap()?;

avro/src/reader.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,7 @@ mod reader {
932932
c: Vec<String>,
933933
}
934934

935-
#[synca::cfg(tokio)]
936-
use async_trait::async_trait;
937-
#[cfg_attr(feature = "tokio", async_trait)]
935+
#[cfg_attr(feature = "tokio", async_trait::async_trait)]
938936
impl AvroSchema for TestSingleObjectReader {
939937
async fn get_schema() -> Schema {
940938
let schema = r#"

avro/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6919,6 +6919,7 @@ mod schema {
69196919
id: Uuid,
69206920
}
69216921

6922+
#[cfg_attr(feature = "tokio", async_trait::async_trait)]
69226923
impl AvroSchema for Comment {
69236924
async fn get_schema() -> Schema {
69246925
Schema::parse_str(

avro/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ mod types {
16171617
});
16181618

16191619
let value = Value::Enum(0, "spades".to_string());
1620-
assert!(!value.validate(&other_schema));
1620+
assert!(!value.validate(&other_schema).await);
16211621
assert_logged(
16221622
format!(
16231623
"Invalid value: {:?} for schema: {:?}. Reason: {}",

avro/src/writer.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ mod writer {
15141514
c: Vec<String>,
15151515
}
15161516

1517+
#[cfg_attr(feature = "tokio", async_trait::async_trait)]
15171518
impl AvroSchema for TestSingleObjectWriter {
15181519
async fn get_schema() -> Schema {
15191520
let schema = r#"
@@ -1565,7 +1566,7 @@ mod writer {
15651566
c: vec!["cat".into(), "dog".into()],
15661567
};
15671568
let mut writer = GenericSingleObjectWriter::new_with_capacity(
1568-
&TestSingleObjectWriter::get_schema(),
1569+
&TestSingleObjectWriter::get_schema().await,
15691570
1024,
15701571
)
15711572
.expect("Should resolve schema");
@@ -1581,14 +1582,14 @@ mod writer {
15811582
assert_eq!(buf[1], 0x01);
15821583
assert_eq!(
15831584
&buf[2..10],
1584-
&TestSingleObjectWriter::get_schema()
1585+
&TestSingleObjectWriter::get_schema().await
15851586
.fingerprint::<Rabin>()
15861587
.bytes[..]
15871588
);
15881589
let mut msg_binary = Vec::new();
15891590
encode(
15901591
&value,
1591-
&TestSingleObjectWriter::get_schema(),
1592+
&TestSingleObjectWriter::get_schema().await,
15921593
&mut msg_binary,
15931594
)
15941595
.expect("encode should have failed by here as a dependency of any writing");
@@ -1608,7 +1609,7 @@ mod writer {
16081609
let schema_uuid = Uuid::parse_str("b2f1cf00-0434-013e-439a-125eb8485a5f")?;
16091610
let header_builder = GlueSchemaUuidHeader::from_uuid(schema_uuid);
16101611
let mut writer = GenericSingleObjectWriter::new_with_capacity_and_header_builder(
1611-
&TestSingleObjectWriter::get_schema(),
1612+
&TestSingleObjectWriter::get_schema().await,
16121613
1024,
16131614
header_builder,
16141615
)
@@ -1638,12 +1639,12 @@ mod writer {
16381639
let mut buf3: Vec<u8> = Vec::new();
16391640

16401641
let mut generic_writer = GenericSingleObjectWriter::new_with_capacity(
1641-
&TestSingleObjectWriter::get_schema(),
1642+
&TestSingleObjectWriter::get_schema().await,
16421643
1024,
16431644
)
16441645
.expect("Should resolve schema");
16451646
let mut specific_writer =
1646-
SpecificSingleObjectWriter::<TestSingleObjectWriter>::with_capacity(1024)
1647+
SpecificSingleObjectWriter::<TestSingleObjectWriter>::with_capacity(1024).await
16471648
.expect("Resolved should pass");
16481649
specific_writer
16491650
.write(obj1.clone(), &mut buf1)

avro/tests/avro-3787.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use apache_avro::schema::tokio::Schema;
19-
use apache_avro::types::tokio::Value;
18+
use apache_avro::Schema;
19+
use apache_avro::types::sync::Value;
2020
use apache_avro::{from_avro_datum, to_avro_datum, to_value};
2121
use apache_avro_test_helper::TestResult;
2222

0 commit comments

Comments
 (0)