(t *testing.T)
| 296 | } |
| 297 | |
| 298 | func TestAddOffsetsToTxn(t *testing.T) { |
| 299 | type testCase struct { |
| 300 | brokerErr KError |
| 301 | initialFlags ProducerTxnStatusFlag |
| 302 | expectedFlags ProducerTxnStatusFlag |
| 303 | expectedError error |
| 304 | newOffsets topicPartitionOffsets |
| 305 | } |
| 306 | |
| 307 | originalOffsets := topicPartitionOffsets{ |
| 308 | topicPartition{topic: "test-topic", partition: 0}: { |
| 309 | Partition: 0, |
| 310 | Offset: 0, |
| 311 | }, |
| 312 | } |
| 313 | |
| 314 | testCases := []testCase{ |
| 315 | { |
| 316 | brokerErr: ErrNoError, |
| 317 | initialFlags: ProducerTxnFlagInTransaction, |
| 318 | expectedFlags: ProducerTxnFlagInTransaction, |
| 319 | expectedError: nil, |
| 320 | newOffsets: topicPartitionOffsets{}, |
| 321 | }, |
| 322 | { |
| 323 | brokerErr: ErrConsumerCoordinatorNotAvailable, |
| 324 | initialFlags: ProducerTxnFlagInTransaction, |
| 325 | expectedFlags: ProducerTxnFlagInTransaction, |
| 326 | expectedError: ErrConsumerCoordinatorNotAvailable, |
| 327 | newOffsets: originalOffsets, |
| 328 | }, |
| 329 | { |
| 330 | brokerErr: ErrNotCoordinatorForConsumer, |
| 331 | initialFlags: ProducerTxnFlagInTransaction, |
| 332 | expectedFlags: ProducerTxnFlagInTransaction, |
| 333 | expectedError: ErrNotCoordinatorForConsumer, |
| 334 | newOffsets: originalOffsets, |
| 335 | }, |
| 336 | { |
| 337 | brokerErr: ErrOffsetsLoadInProgress, |
| 338 | initialFlags: ProducerTxnFlagInTransaction, |
| 339 | expectedFlags: ProducerTxnFlagInTransaction, |
| 340 | expectedError: ErrOffsetsLoadInProgress, |
| 341 | newOffsets: originalOffsets, |
| 342 | }, |
| 343 | { |
| 344 | brokerErr: ErrConcurrentTransactions, |
| 345 | initialFlags: ProducerTxnFlagInTransaction, |
| 346 | expectedFlags: ProducerTxnFlagInTransaction, |
| 347 | expectedError: ErrConcurrentTransactions, |
| 348 | newOffsets: originalOffsets, |
| 349 | }, |
| 350 | { |
| 351 | brokerErr: ErrUnknownProducerID, |
| 352 | initialFlags: ProducerTxnFlagInTransaction, |
| 353 | expectedFlags: ProducerTxnFlagFatalError, |
| 354 | expectedError: ErrUnknownProducerID, |
| 355 | newOffsets: originalOffsets, |
nothing calls this directly
no test coverage detected