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

Function TestAddOffsetsToTxn

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

Source from the content-addressed store, hash-verified

296}
297
298func 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,

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
ReturnsMethod · 0.95
NewMockBrokerFunction · 0.85
newMockTxnManagerFunction · 0.85
NewConsumerGroupMetadataFunction · 0.85
IsMethod · 0.80
publishOffsetsToTxnMethod · 0.80
NewTestConfigFunction · 0.70
CloseMethod · 0.65
BrokersMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected