SyncProducer implements sarama's SyncProducer interface for testing purposes. Before you can use it, you have to set expectations on the mock SyncProducer to tell it how to handle calls to SendMessage, so you can easily test success and failure scenarios.
| 12 | // to tell it how to handle calls to SendMessage, so you can easily test success |
| 13 | // and failure scenarios. |
| 14 | type SyncProducer struct { |
| 15 | l sync.Mutex |
| 16 | t ErrorReporter |
| 17 | expectations []*producerExpectation |
| 18 | lastOffset int64 |
| 19 | |
| 20 | *TopicConfig |
| 21 | newPartitioner sarama.PartitionerConstructor |
| 22 | partitioners map[string]sarama.Partitioner |
| 23 | |
| 24 | isTransactional bool |
| 25 | txnLock sync.Mutex |
| 26 | txnStatus sarama.ProducerTxnStatusFlag |
| 27 | } |
| 28 | |
| 29 | // NewSyncProducer instantiates a new SyncProducer mock. The t argument should |
| 30 | // be the *testing.T instance of your test method. An error will be written to it if |
nothing calls this directly
no outgoing calls
no test coverage detected