Debian Codegraph @

listpartitionreassignments_test.go

raw symbols SCIP
1 package kafka
2
3 import (
4 "context"
5 "testing"
6
7 ktesting "github.com/segmentio/kafka-go/testing"
8 )
9
10 func TestClientListPartitionReassignments(t *testing.T) {
11 if !ktesting.KafkaIsAtLeast("2.4.0") {
12 return
13 }
14
15 ctx := context.Background()
16 client, shutdown := newLocalClient()
17 defer shutdown()
18
19 topic := makeTopic()
20 createTopic(t, topic, 2)
21 defer deleteTopic(t, topic)
22
23 // Can't really get an ongoing partition reassignment with local Kafka, so just do a superficial test here.
24 resp, err := client.ListPartitionReassignments(
25 ctx,
26 &ListPartitionReassignmentsRequest{
27 Topics: map[string]ListPartitionReassignmentsRequestTopic{
28 topic: {PartitionIndexes: []int{0, 1}},
29 },
30 },
31 )
32
33 if err != nil {
34 t.Fatal(err)
35 }
36 if resp.Error != nil {
37 t.Error(
38 "Unexpected error in response",
39 "expected", nil,
40 "got", resp.Error,
41 )
42 }
43 if len(resp.Topics) != 0 {
44 t.Error(
45 "Unexpected length of topic results",
46 "expected", 0,
47 "got", len(resp.Topics),
48 )
49 }
50 }