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

Function TestProducerWithTooManyExpectations

mocks/async_producer_test.go:97–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestProducerWithTooManyExpectations(t *testing.T) {
98 trm := newTestReporterMock()
99 mp := NewAsyncProducer(trm, nil).
100 ExpectInputAndSucceed().
101 ExpectInputAndFail(sarama.ErrOutOfBrokers)
102
103 mp.Input() <- &sarama.ProducerMessage{Topic: "test"}
104 if err := mp.Close(); err != nil {
105 t.Error(err)
106 }
107
108 if len(trm.errors) != 1 {
109 t.Error("Expected to report an error")
110 }
111}
112
113func TestProducerFailTxn(t *testing.T) {
114 config := NewTestConfig()

Callers

nothing calls this directly

Calls 7

newTestReporterMockFunction · 0.85
ExpectInputAndFailMethod · 0.80
ExpectInputAndSucceedMethod · 0.80
NewAsyncProducerFunction · 0.70
InputMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected