Skip to content

Commit

Permalink
Release 0.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxrgd committed Sep 1, 2023
1 parent 9734c01 commit 727bcb5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsgen-avro"
version = "0.12.1"
version = "0.12.2"
authors = ["Romain Leroux <romain@leroux.dev>"]
edition = "2021"
description = "Command line and library for generating Rust types from Avro schemas"
Expand Down
5 changes: 5 additions & 0 deletions tests/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ fn gen_enums() {
validate_generation("enums", Generator::new().unwrap());
}

#[test]
fn gen_enums_casing() {
validate_generation("enums_casing", Generator::new().unwrap());
}

#[test]
fn gen_enums_multiline_doc() {
validate_generation("enums_multiline_doc", Generator::new().unwrap());
Expand Down
25 changes: 25 additions & 0 deletions tests/schemas/enums_casing.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "record",
"name": "MyRecord",
"namespace": "com.example.data",
"doc": "Record doc",
"fields": [
{
"name": "id",
"type": "int",
"doc": "Identifier"
},
{
"name": "unit",
"type": {
"type": "enum",
"name": "MeasurementUnit",
"symbols": [
"mJ"
]
},
"doc": "Measurement unit",
"default": "mJ"
}
]
}
17 changes: 17 additions & 0 deletions tests/schemas/enums_casing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, serde::Deserialize, serde::Serialize)]
pub enum MeasurementUnit {
#[serde(rename = "mJ")]
MJ,
}

/// Record doc
#[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)]
pub struct MyRecord {
pub id: i32,
#[serde(default = "default_myrecord_unit")]
pub unit: MeasurementUnit,
}

#[inline(always)]
fn default_myrecord_unit() -> MeasurementUnit { MeasurementUnit::MJ }
1 change: 1 addition & 0 deletions tests/schemas/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod complex;
pub mod enums;
pub mod enums_casing;
pub mod enums_multiline_doc;
pub mod enums_sanitize;
#[allow(dead_code)]
Expand Down

0 comments on commit 727bcb5

Please sign in to comment.