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

Function TestSyncProducerWithTooManyExpectations

mocks/sync_producer_test.go:158–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestSyncProducerWithTooManyExpectations(t *testing.T) {
159 trm := newTestReporterMock()
160
161 sp := NewSyncProducer(trm, nil).
162 ExpectSendMessageAndSucceed().
163 ExpectSendMessageAndFail(sarama.ErrOutOfBrokers)
164
165 msg := &sarama.ProducerMessage{Topic: "test", Value: sarama.StringEncoder("test")}
166 if _, _, err := sp.SendMessage(msg); err != nil {
167 t.Error("No error expected on first SendMessage call", err)
168 }
169
170 if err := sp.Close(); err != nil {
171 t.Error(err)
172 }
173
174 if len(trm.errors) != 1 {
175 t.Error("Expected to report an error")
176 }
177}
178
179func TestSyncProducerWithTooFewExpectations(t *testing.T) {
180 trm := newTestReporterMock()

Callers

nothing calls this directly

Calls 8

StringEncoderTypeAlias · 0.92
newTestReporterMockFunction · 0.85
NewSyncProducerFunction · 0.70
SendMessageMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected