(t *testing.T)
| 516 | } |
| 517 | |
| 518 | func TestConsumerInvalidTopic(t *testing.T) { |
| 519 | // Given |
| 520 | broker0 := NewMockBroker(t, 100) |
| 521 | broker0.SetHandlerByMap(map[string]MockResponse{ |
| 522 | "MetadataRequest": NewMockMetadataResponse(t). |
| 523 | SetBroker(broker0.Addr(), broker0.BrokerID()), |
| 524 | }) |
| 525 | |
| 526 | c, err := NewConsumer([]string{broker0.Addr()}, NewTestConfig()) |
| 527 | if err != nil { |
| 528 | t.Fatal(err) |
| 529 | } |
| 530 | |
| 531 | // When |
| 532 | pc, err := c.ConsumePartition("my_topic", 0, OffsetOldest) |
| 533 | |
| 534 | // Then |
| 535 | if pc != nil || !errors.Is(err, ErrUnknownTopicOrPartition) { |
| 536 | t.Errorf("Should fail with, err=%v", err) |
| 537 | } |
| 538 | |
| 539 | safeClose(t, c) |
| 540 | broker0.Close() |
| 541 | } |
| 542 | |
| 543 | // Nothing bad happens if a partition consumer that has no leader assigned at |
| 544 | // the moment is closed. |
nothing calls this directly
no test coverage detected