MCPcopy
hub / github.com/segmentio/kafka-go / TestListRe

Function TestListRe

topics/list_topics_test.go:21–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestListRe(t *testing.T) {
22 client, shutdown := newLocalClientWithTopic("TestTopics-A", 1)
23 defer shutdown()
24 clientCreateTopic(client, "TestTopics-B", 1)
25
26 allRegex := regexp.MustCompile("TestTopics-.*")
27 fooRegex := regexp.MustCompile("TestTopics-B")
28
29 // Get all the topics
30 topics, err := ListRe(context.Background(), client, allRegex)
31 if err != nil {
32 t.Fatal(err)
33 }
34 if len(topics) != 2 {
35 t.Error("the wrong number of topics were returned. ", len(topics))
36 }
37
38 // Get one topic
39 topics, err = ListRe(context.Background(), client, fooRegex)
40 if err != nil {
41 t.Fatal(err)
42 }
43 if len(topics) != 1 {
44 t.Error("the wrong number of topics were returned. ", len(topics))
45 }
46}
47
48func newLocalClientWithTopic(topic string, partitions int) (*kafka.Client, func()) {
49 client, shutdown := newLocalClient()

Callers

nothing calls this directly

Calls 4

ListReFunction · 0.85
newLocalClientWithTopicFunction · 0.70
clientCreateTopicFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected