@@ -76,8 +76,8 @@ func TestValidation(t *testing.T) {
7676 asyncapi3test .WithKey (schematest .New ("integer" )),
7777 ),
7878 asyncapi3test .WithKafkaChannelBinding (asyncapi3.TopicBindings {
79- Partitions : 1 ,
8079 KeySchemaValidation : false ,
80+ Partitions : 1 ,
8181 }),
8282 ),
8383 ),
@@ -92,6 +92,44 @@ func TestValidation(t *testing.T) {
9292 })
9393 require .NoError (t , err )
9494 require .Len (t , batch , 0 )
95+
96+ e := events .GetEvents (events .NewTraits ())
97+ require .Len (t , e , 1 )
98+ require .Equal (t , []byte ("foo" ), e [0 ].Data .(* store.KafkaLog ).Key .Binary )
99+ },
100+ },
101+ {
102+ name : "validating value and key" ,
103+ cfg : asyncapi3test .NewConfig (
104+ asyncapi3test .WithChannel ("foo" ,
105+ asyncapi3test .WithMessage ("foo" ,
106+ asyncapi3test .WithPayload (schematest .New ("string" )),
107+ asyncapi3test .WithKey (schematest .New ("string" )),
108+ ),
109+ asyncapi3test .WithKafkaChannelBinding (asyncapi3.TopicBindings {
110+ KeySchemaValidation : true ,
111+ ValueSchemaValidation : true ,
112+ Partitions : 1 ,
113+ }),
114+ ),
115+ ),
116+ test : func (t * testing.T , s * store.Store ) {
117+ p := s .Topic ("foo" ).Partition (0 )
118+ _ , batch , err := p .Write (kafka.RecordBatch {
119+ Records : []* kafka.Record {
120+ {
121+ Key : kafka .NewBytes ([]byte ("12" )),
122+ Value : kafka .NewBytes ([]byte ("foo" )),
123+ },
124+ },
125+ })
126+ require .NoError (t , err )
127+ require .Len (t , batch , 0 )
128+
129+ e := events .GetEvents (events .NewTraits ())
130+ require .Len (t , e , 1 )
131+ require .Equal (t , `"12"` , e [0 ].Data .(* store.KafkaLog ).Key .Value )
132+ require .Equal (t , `"foo"` , e [0 ].Data .(* store.KafkaLog ).Message .Value )
95133 },
96134 },
97135 {
0 commit comments