(t *testing.T)
| 517 | } |
| 518 | |
| 519 | func TestTxnOffsetsCommit(t *testing.T) { |
| 520 | type testCase struct { |
| 521 | brokerErr KError |
| 522 | initialFlags ProducerTxnStatusFlag |
| 523 | initialOffsets topicPartitionOffsets |
| 524 | expectedFlags ProducerTxnStatusFlag |
| 525 | expectedError error |
| 526 | expectedOffsets topicPartitionOffsets |
| 527 | } |
| 528 | |
| 529 | originalOffsets := topicPartitionOffsets{ |
| 530 | topicPartition{topic: "test-topic", partition: 0}: { |
| 531 | Partition: 0, |
| 532 | Offset: 0, |
| 533 | }, |
| 534 | } |
| 535 | |
| 536 | testCases := []testCase{ |
| 537 | { |
| 538 | brokerErr: ErrConsumerCoordinatorNotAvailable, |
| 539 | initialFlags: ProducerTxnFlagInTransaction, |
| 540 | initialOffsets: topicPartitionOffsets{ |
| 541 | topicPartition{topic: "test-topic", partition: 0}: { |
| 542 | Partition: 0, |
| 543 | Offset: 0, |
| 544 | }, |
| 545 | }, |
| 546 | expectedFlags: ProducerTxnFlagInTransaction, |
| 547 | expectedError: Wrap(ErrTxnOffsetCommit, ErrConsumerCoordinatorNotAvailable), |
| 548 | expectedOffsets: originalOffsets, |
| 549 | }, |
| 550 | { |
| 551 | brokerErr: ErrNotCoordinatorForConsumer, |
| 552 | initialFlags: ProducerTxnFlagInTransaction, |
| 553 | initialOffsets: topicPartitionOffsets{ |
| 554 | topicPartition{topic: "test-topic", partition: 0}: { |
| 555 | Partition: 0, |
| 556 | Offset: 0, |
| 557 | }, |
| 558 | }, |
| 559 | expectedFlags: ProducerTxnFlagInTransaction, |
| 560 | expectedError: Wrap(ErrTxnOffsetCommit, ErrNotCoordinatorForConsumer), |
| 561 | expectedOffsets: originalOffsets, |
| 562 | }, |
| 563 | { |
| 564 | brokerErr: ErrNoError, |
| 565 | initialFlags: ProducerTxnFlagInTransaction, |
| 566 | initialOffsets: topicPartitionOffsets{ |
| 567 | topicPartition{topic: "test-topic", partition: 0}: { |
| 568 | Partition: 0, |
| 569 | Offset: 0, |
| 570 | }, |
| 571 | }, |
| 572 | expectedFlags: ProducerTxnFlagInTransaction, |
| 573 | expectedError: nil, |
| 574 | expectedOffsets: topicPartitionOffsets{}, |
| 575 | }, |
| 576 | { |
nothing calls this directly
no test coverage detected