MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_enum_no_reader_schema

Function test_enum_no_reader_schema

src/avro/src/lib.rs:680–718  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

678 //TODO: move where it fits better
679 #[mz_ore::test]
680 fn test_enum_no_reader_schema() {
681 let writer_raw_schema = r#"
682 {
683 "type": "record",
684 "name": "test",
685 "fields": [
686 {"name": "a", "type": "long", "default": 42},
687 {"name": "b", "type": "string"},
688 {
689 "name": "c",
690 "type": {
691 "type": "enum",
692 "name": "suit",
693 "symbols": ["diamonds", "spades", "clubs", "hearts"]
694 },
695 "default": "spades"
696 }
697 ]
698 }
699 "#;
700 let writer_schema = Schema::from_str(writer_raw_schema).unwrap();
701 let mut writer = Writer::with_codec(writer_schema.clone(), Vec::new(), Codec::Null);
702 let mut record = Record::new(writer_schema.top_node()).unwrap();
703 record.put("a", 27i64);
704 record.put("b", "foo");
705 record.put("c", "clubs");
706 writer.append(record).unwrap();
707 writer.flush().unwrap();
708 let input = writer.into_inner();
709 let mut reader = Reader::new(&input[..]).unwrap();
710 assert_eq!(
711 reader.next().unwrap().unwrap(),
712 Value::Record(vec![
713 ("a".to_string(), Value::Long(27)),
714 ("b".to_string(), Value::String("foo".to_string())),
715 ("c".to_string(), Value::Enum(2, "clubs".to_string())),
716 ])
717 );
718 }
719 #[mz_ore::test]
720 fn test_datetime_value() {
721 let writer_raw_schema = r#"{

Callers

nothing calls this directly

Calls 7

unwrapMethod · 0.80
top_nodeMethod · 0.80
putMethod · 0.80
cloneMethod · 0.45
appendMethod · 0.45
flushMethod · 0.45
into_innerMethod · 0.45

Tested by

no test coverage detected