MCPcopy
hub / github.com/IBM/sarama / TestPublishPartitionToTxn

Function TestPublishPartitionToTxn

transaction_manager_test.go:824–975  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

822}
823
824func 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,

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
ReturnsMethod · 0.95
WrapFunction · 0.85
NewMockBrokerFunction · 0.85
newMockTxnManagerFunction · 0.85
IsMethod · 0.80
publishTxnPartitionsMethod · 0.80
NewTestConfigFunction · 0.70
CloseMethod · 0.65
BrokersMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected