MCPcopy
hub / github.com/IBM/sarama / TestClusterAdminCreateTopic

Function TestClusterAdminCreateTopic

admin_test.go:65–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestClusterAdminCreateTopic(t *testing.T) {
66 seedBroker := NewMockBroker(t, 1)
67 defer seedBroker.Close()
68
69 seedBroker.SetHandlerByMap(map[string]MockResponse{
70 "MetadataRequest": NewMockMetadataResponse(t).
71 SetController(seedBroker.BrokerID()).
72 SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
73 "CreateTopicsRequest": NewMockCreateTopicsResponse(t),
74 })
75
76 config := NewTestConfig()
77 config.Version = V0_10_2_0
78 admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
79 if err != nil {
80 t.Fatal(err)
81 }
82 err = admin.CreateTopic("my_topic", &TopicDetail{NumPartitions: 1, ReplicationFactor: 1}, false)
83 if err != nil {
84 t.Fatal(err)
85 }
86
87 err = admin.Close()
88 if err != nil {
89 t.Fatal(err)
90 }
91}
92
93func TestClusterAdminCreateTopicWithInvalidTopicDetail(t *testing.T) {
94 seedBroker := NewMockBroker(t, 1)

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
SetHandlerByMapMethod · 0.95
BrokerIDMethod · 0.95
AddrMethod · 0.95
CreateTopicMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
NewClusterAdminFunction · 0.85
SetBrokerMethod · 0.80
SetControllerMethod · 0.80

Tested by

no test coverage detected