| 1247 | } |
| 1248 | |
| 1249 | func TestValidateReader(t *testing.T) { |
| 1250 | tests := []struct { |
| 1251 | config ReaderConfig |
| 1252 | errorOccured bool |
| 1253 | }{ |
| 1254 | {config: ReaderConfig{}, errorOccured: true}, |
| 1255 | {config: ReaderConfig{Brokers: []string{"broker1"}}, errorOccured: true}, |
| 1256 | {config: ReaderConfig{Brokers: []string{"broker1"}, Topic: "topic1"}, errorOccured: false}, |
| 1257 | {config: ReaderConfig{Brokers: []string{"broker1"}, Topic: "topic1", Partition: -1}, errorOccured: true}, |
| 1258 | {config: ReaderConfig{Brokers: []string{"broker1"}, Topic: "topic1", Partition: 1, MinBytes: -1}, errorOccured: true}, |
| 1259 | {config: ReaderConfig{Brokers: []string{"broker1"}, Topic: "topic1", Partition: 1, MinBytes: 5, MaxBytes: -1}, errorOccured: true}, |
| 1260 | {config: ReaderConfig{Brokers: []string{"broker1"}, Topic: "topic1", Partition: 1, MinBytes: 5, MaxBytes: 6}, errorOccured: false}, |
| 1261 | } |
| 1262 | for _, test := range tests { |
| 1263 | err := test.config.Validate() |
| 1264 | if test.errorOccured && err == nil { |
| 1265 | t.Fail() |
| 1266 | } |
| 1267 | if !test.errorOccured && err != nil { |
| 1268 | t.Fail() |
| 1269 | } |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | func TestCommitLoopImmediateFlushOnGenerationEnd(t *testing.T) { |
| 1274 | t.Parallel() |