in avro/src/schema.rs [3280:3346]
fn test_avro_3302_record_schema_with_currently_parsing_schema_aliases() -> TestResult {
let schema = Schema::parse_str(
r#"
{
"type": "record",
"name": "LongList",
"aliases": ["LinkedLongs"],
"fields" : [
{"name": "value", "type": "long"},
{"name": "next", "type": ["null", "LinkedLongs"]}
]
}
"#,
)?;
let mut lookup = BTreeMap::new();
lookup.insert("value".to_owned(), 0);
lookup.insert("next".to_owned(), 1);
let expected = Schema::Record(RecordSchema {
name: Name {
name: "LongList".to_owned(),
namespace: None,
},
aliases: Some(vec![Alias::new("LinkedLongs").unwrap()]),
doc: None,
fields: vec![
RecordField {
name: "value".to_string(),
doc: None,
default: None,
aliases: None,
schema: Schema::Long,
order: RecordFieldOrder::Ascending,
position: 0,
custom_attributes: Default::default(),
},
RecordField {
name: "next".to_string(),
doc: None,
default: None,
aliases: None,
schema: Schema::Union(UnionSchema::new(vec![
Schema::Null,
Schema::Ref {
name: Name {
name: "LongList".to_owned(),
namespace: None,
},
},
])?),
order: RecordFieldOrder::Ascending,
position: 1,
custom_attributes: Default::default(),
},
],
lookup,
attributes: Default::default(),
});
assert_eq!(schema, expected);
let canonical_form = &schema.canonical_form();
let expected = r#"{"name":"LongList","type":"record","fields":[{"name":"value","type":"long"},{"name":"next","type":["null","LongList"]}]}"#;
assert_eq!(canonical_form, &expected);
Ok(())
}