(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestSyncProducerFailTxn(t *testing.T) { |
| 61 | config := NewTestConfig() |
| 62 | config.Producer.Transaction.ID = "test" |
| 63 | config.Producer.RequiredAcks = sarama.WaitForAll |
| 64 | config.Producer.Retry.Backoff = 0 |
| 65 | config.Producer.Idempotent = true |
| 66 | config.Net.MaxOpenRequests = 1 |
| 67 | config.Version = sarama.V0_11_0_0 |
| 68 | |
| 69 | tfm := newTestReporterMock() |
| 70 | |
| 71 | sp := NewSyncProducer(tfm, config) |
| 72 | defer func() { |
| 73 | if err := sp.Close(); err != nil { |
| 74 | t.Error(err) |
| 75 | } |
| 76 | }() |
| 77 | |
| 78 | msg := &sarama.ProducerMessage{Topic: "test", Value: sarama.StringEncoder("test")} |
| 79 | |
| 80 | _, _, err := sp.SendMessage(msg) |
| 81 | if err == nil { |
| 82 | t.Errorf("must have failed with txn begin error") |
| 83 | } |
| 84 | |
| 85 | if len(tfm.errors) != 1 { |
| 86 | t.Errorf("must have failed with txn begin error") |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TestSyncProducerUseTxn(t *testing.T) { |
| 91 | config := NewTestConfig() |
nothing calls this directly
no test coverage detected