(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestConnCreateTopics(t *testing.T) { |
| 15 | topic1 := makeTopic() |
| 16 | topic2 := makeTopic() |
| 17 | |
| 18 | conn, err := DialContext(context.Background(), "tcp", "localhost:9092") |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | |
| 23 | defer func() { |
| 24 | err := conn.Close() |
| 25 | if err != nil { |
| 26 | t.Fatalf("failed to close connection: %v", err) |
| 27 | } |
| 28 | }() |
| 29 | |
| 30 | controller, _ := conn.Controller() |
| 31 | |
| 32 | controllerConn, err := Dial("tcp", net.JoinHostPort(controller.Host, strconv.Itoa(controller.Port))) |
| 33 | if err != nil { |
| 34 | t.Fatal(err) |
| 35 | } |
| 36 | defer controllerConn.Close() |
| 37 | |
| 38 | err = controllerConn.CreateTopics(TopicConfig{ |
| 39 | Topic: topic1, |
| 40 | NumPartitions: 1, |
| 41 | ReplicationFactor: 1, |
| 42 | }) |
| 43 | if err != nil { |
| 44 | t.Fatalf("unexpected error creating topic: %s", err.Error()) |
| 45 | } |
| 46 | |
| 47 | err = controllerConn.CreateTopics(TopicConfig{ |
| 48 | Topic: topic1, |
| 49 | NumPartitions: 1, |
| 50 | ReplicationFactor: 1, |
| 51 | }) |
| 52 | |
| 53 | // Duplicate topic should not return an error |
| 54 | if err != nil { |
| 55 | t.Fatalf("unexpected error creating duplicate topic topic: %v", err) |
| 56 | } |
| 57 | |
| 58 | err = controllerConn.CreateTopics( |
| 59 | TopicConfig{ |
| 60 | Topic: topic1, |
| 61 | NumPartitions: 1, |
| 62 | ReplicationFactor: 1, |
| 63 | }, |
| 64 | TopicConfig{ |
| 65 | Topic: topic2, |
| 66 | NumPartitions: 1, |
| 67 | ReplicationFactor: 1, |
| 68 | }, |
| 69 | TopicConfig{ |
| 70 | Topic: topic2, |
| 71 | NumPartitions: 1, |
nothing calls this directly
no test coverage detected