| 308 | } |
| 309 | |
| 310 | func TestValidateWriter(t *testing.T) { |
| 311 | tests := []struct { |
| 312 | config WriterConfig |
| 313 | errorOccured bool |
| 314 | }{ |
| 315 | {config: WriterConfig{}, errorOccured: true}, |
| 316 | {config: WriterConfig{Brokers: []string{"broker1", "broker2"}}, errorOccured: false}, |
| 317 | {config: WriterConfig{Brokers: []string{"broker1"}, Topic: "topic1"}, errorOccured: false}, |
| 318 | } |
| 319 | for _, test := range tests { |
| 320 | err := test.config.Validate() |
| 321 | if test.errorOccured && err == nil { |
| 322 | t.Fail() |
| 323 | } |
| 324 | if !test.errorOccured && err != nil { |
| 325 | t.Fail() |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | func testWriterMaxAttemptsErr(t *testing.T) { |
| 331 | topic := makeTopic() |