@@ -40,6 +40,40 @@ func TestRecord_ReadFrom(t *testing.T) {
4040 require .NoError (t , err )
4141 },
4242 },
43+ {
44+ name : "one record v1" ,
45+ data : []byte {
46+ 0 , 0 , 0 , 58 , // length
47+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 12 , // offset
48+ 0 , 0 , 0 , 1 , // batch length
49+ 0 , 0 , 0 , 0 , // crc
50+ 1 , // magic
51+ 0 , // attributes
52+ 0 , 0 , 1 , 125 , 158 , 189 , 76 , 76 , // timestamp
53+
54+ 0 , 0 , 0 , 3 , // key length
55+ 'f' , 'o' , 'o' , // key
56+ 0 , 0 , 0 , 3 , // value length
57+ 'b' , 'a' , 'r' , // value
58+ },
59+ test : func (t * testing.T , d * Decoder ) {
60+ batch := RecordBatch {}
61+ err := batch .ReadFrom (d , 0 , kafkaTag {})
62+ require .NoError (t , err )
63+ require .Len (t , batch .Records , 1 )
64+ record := batch .Records [0 ]
65+ require .Equal (t , int64 (12 ), record .Offset )
66+ var b [3 ]byte
67+ record .Key .Read (b [:])
68+ require .Equal (t , "foo" , string (b [:]))
69+ record .Value .Read (b [:])
70+ require .Equal (t , "bar" , string (b [:]))
71+ y , m , day := record .Time .Date ()
72+ require .Equal (t , 2021 , y )
73+ require .Equal (t , time .December , m )
74+ require .Equal (t , 9 , day )
75+ },
76+ },
4377 {
4478 name : "one record v2" ,
4579 data : []byte {
0 commit comments