(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func TestConsumerTopicMetadata(t *testing.T) { |
| 282 | trm := newTestReporterMock() |
| 283 | consumer := NewConsumer(trm, NewTestConfig()) |
| 284 | |
| 285 | consumer.SetTopicMetadata(map[string][]int32{ |
| 286 | "test1": {0, 1, 2, 3}, |
| 287 | "test2": {0, 1, 2, 3, 4, 5, 6, 7}, |
| 288 | }) |
| 289 | |
| 290 | topics, err := consumer.Topics() |
| 291 | if err != nil { |
| 292 | t.Error(t) |
| 293 | } |
| 294 | |
| 295 | sortedTopics := sort.StringSlice(topics) |
| 296 | sortedTopics.Sort() |
| 297 | if len(sortedTopics) != 2 || sortedTopics[0] != "test1" || sortedTopics[1] != "test2" { |
| 298 | t.Error("Unexpected topics returned:", sortedTopics) |
| 299 | } |
| 300 | |
| 301 | partitions1, err := consumer.Partitions("test1") |
| 302 | if err != nil { |
| 303 | t.Error(t) |
| 304 | } |
| 305 | |
| 306 | if len(partitions1) != 4 { |
| 307 | t.Error("Unexpected partitions returned:", len(partitions1)) |
| 308 | } |
| 309 | |
| 310 | partitions2, err := consumer.Partitions("test2") |
| 311 | if err != nil { |
| 312 | t.Error(t) |
| 313 | } |
| 314 | |
| 315 | if len(partitions2) != 8 { |
| 316 | t.Error("Unexpected partitions returned:", len(partitions2)) |
| 317 | } |
| 318 | |
| 319 | if len(trm.errors) != 0 { |
| 320 | t.Errorf("Expected no expectation failures to be set on the error reporter.") |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | func TestConsumerUnexpectedTopicMetadata(t *testing.T) { |
| 325 | trm := newTestReporterMock() |
nothing calls this directly
no test coverage detected