(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func TestSyncProducerWithTooFewExpectations(t *testing.T) { |
| 180 | trm := newTestReporterMock() |
| 181 | |
| 182 | sp := NewSyncProducer(trm, nil).ExpectSendMessageAndSucceed() |
| 183 | |
| 184 | msg := &sarama.ProducerMessage{Topic: "test", Value: sarama.StringEncoder("test")} |
| 185 | if _, _, err := sp.SendMessage(msg); err != nil { |
| 186 | t.Error("No error expected on first SendMessage call", err) |
| 187 | } |
| 188 | if _, _, err := sp.SendMessage(msg); !errors.Is(err, errOutOfExpectations) { |
| 189 | t.Error("errOutOfExpectations expected on second SendMessage call, found:", err) |
| 190 | } |
| 191 | |
| 192 | if err := sp.Close(); err != nil { |
| 193 | t.Error(err) |
| 194 | } |
| 195 | |
| 196 | if len(trm.errors) != 1 { |
| 197 | t.Error("Expected to report an error") |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | func TestSyncProducerWithCheckerFunction(t *testing.T) { |
| 202 | trm := newTestReporterMock() |
nothing calls this directly
no test coverage detected