forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffsetfetch_test.go
More file actions
45 lines (41 loc) · 805 Bytes
/
offsetfetch_test.go
File metadata and controls
45 lines (41 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package kafka
import (
"bufio"
"bytes"
"reflect"
"testing"
)
func TestOffsetFetchResponseV1(t *testing.T) {
item := offsetFetchResponseV1{
Responses: []offsetFetchResponseV1Response{
{
Topic: "a",
PartitionResponses: []offsetFetchResponseV1PartitionResponse{
{
Partition: 2,
Offset: 3,
Metadata: "b",
ErrorCode: 4,
},
},
},
},
}
b := bytes.NewBuffer(nil)
w := &writeBuffer{w: b}
item.writeTo(w)
var found offsetFetchResponseV1
remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
if err != nil {
t.Error(err)
t.FailNow()
}
if remain != 0 {
t.Errorf("expected 0 remain, got %v", remain)
t.FailNow()
}
if !reflect.DeepEqual(item, found) {
t.Error("expected item and found to be the same")
t.FailNow()
}
}