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

Function TestConsumerInvalidTopic

consumer_test.go:518–541  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

516}
517
518func 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.

Callers

nothing calls this directly

Calls 14

SetHandlerByMapMethod · 0.95
AddrMethod · 0.95
BrokerIDMethod · 0.95
ConsumePartitionMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
SetBrokerMethod · 0.80
FatalMethod · 0.80
IsMethod · 0.80
NewConsumerFunction · 0.70
NewTestConfigFunction · 0.70

Tested by

no test coverage detected