(t *testing.T)
| 822 | } |
| 823 | |
| 824 | func TestPublishPartitionToTxn(t *testing.T) { |
| 825 | type testCase struct { |
| 826 | brokerErr KError |
| 827 | expectedFlags ProducerTxnStatusFlag |
| 828 | expectedError error |
| 829 | expectedPendingPartitions topicPartitionSet |
| 830 | expectedPartitionsInTxn topicPartitionSet |
| 831 | } |
| 832 | |
| 833 | initialPendingTopicPartitionSet := topicPartitionSet{ |
| 834 | { |
| 835 | topic: "test-topic", |
| 836 | partition: 0, |
| 837 | }: struct{}{}, |
| 838 | } |
| 839 | |
| 840 | testCases := []testCase{ |
| 841 | { |
| 842 | brokerErr: ErrNoError, |
| 843 | expectedFlags: ProducerTxnFlagInTransaction, |
| 844 | expectedError: nil, |
| 845 | expectedPendingPartitions: topicPartitionSet{}, |
| 846 | expectedPartitionsInTxn: initialPendingTopicPartitionSet, |
| 847 | }, |
| 848 | { |
| 849 | brokerErr: ErrConsumerCoordinatorNotAvailable, |
| 850 | expectedFlags: ProducerTxnFlagInTransaction, |
| 851 | expectedError: Wrap(ErrAddPartitionsToTxn, ErrConsumerCoordinatorNotAvailable), |
| 852 | expectedPartitionsInTxn: topicPartitionSet{}, |
| 853 | expectedPendingPartitions: initialPendingTopicPartitionSet, |
| 854 | }, |
| 855 | { |
| 856 | brokerErr: ErrNotCoordinatorForConsumer, |
| 857 | expectedFlags: ProducerTxnFlagInTransaction, |
| 858 | expectedError: Wrap(ErrAddPartitionsToTxn, ErrNotCoordinatorForConsumer), |
| 859 | expectedPartitionsInTxn: topicPartitionSet{}, |
| 860 | expectedPendingPartitions: initialPendingTopicPartitionSet, |
| 861 | }, |
| 862 | { |
| 863 | brokerErr: ErrUnknownTopicOrPartition, |
| 864 | expectedFlags: ProducerTxnFlagInTransaction, |
| 865 | expectedError: Wrap(ErrAddPartitionsToTxn, ErrUnknownTopicOrPartition), |
| 866 | expectedPartitionsInTxn: topicPartitionSet{}, |
| 867 | expectedPendingPartitions: initialPendingTopicPartitionSet, |
| 868 | }, |
| 869 | { |
| 870 | brokerErr: ErrOffsetsLoadInProgress, |
| 871 | expectedFlags: ProducerTxnFlagInTransaction, |
| 872 | expectedError: Wrap(ErrAddPartitionsToTxn, ErrOffsetsLoadInProgress), |
| 873 | expectedPartitionsInTxn: topicPartitionSet{}, |
| 874 | expectedPendingPartitions: initialPendingTopicPartitionSet, |
| 875 | }, |
| 876 | { |
| 877 | brokerErr: ErrConcurrentTransactions, |
| 878 | expectedFlags: ProducerTxnFlagInTransaction, |
| 879 | expectedError: Wrap(ErrAddPartitionsToTxn, ErrConcurrentTransactions), |
| 880 | expectedPartitionsInTxn: topicPartitionSet{}, |
| 881 | expectedPendingPartitions: initialPendingTopicPartitionSet, |
nothing calls this directly
no test coverage detected