-
Notifications
You must be signed in to change notification settings - Fork 790
/
deletetopics_test.go
56 lines (47 loc) · 1001 Bytes
/
deletetopics_test.go
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
46
47
48
49
50
51
52
53
54
55
56
package kafka
import (
"bufio"
"bytes"
"context"
"reflect"
"testing"
)
func TestClientDeleteTopics(t *testing.T) {
client, shutdown := newLocalClient()
defer shutdown()
topic := makeTopic()
createTopic(t, topic, 1)
res, err := client.DeleteTopics(context.Background(), &DeleteTopicsRequest{
Topics: []string{topic},
})
if err != nil {
t.Fatal(err)
}
if err := res.Errors[topic]; err != nil {
t.Error(err)
}
}
func TestDeleteTopicsResponseV1(t *testing.T) {
item := deleteTopicsResponseV0{
TopicErrorCodes: []deleteTopicsResponseV0TopicErrorCode{
{
Topic: "a",
ErrorCode: 7,
},
},
}
b := bytes.NewBuffer(nil)
w := &writeBuffer{w: b}
item.writeTo(w)
var found deleteTopicsResponseV0
remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
if err != nil {
t.Fatal(err)
}
if remain != 0 {
t.Fatalf("expected 0 remain, got %v", remain)
}
if !reflect.DeepEqual(item, found) {
t.Fatal("expected item and found to be the same")
}
}