github.com/deanMdreon/kafka-go@v0.4.32/protocol/initproducerid/initproducerid_test.go (about)

     1  package initproducerid_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/deanMdreon/kafka-go/protocol/initproducerid"
     7  	"github.com/deanMdreon/kafka-go/protocol/prototest"
     8  )
     9  
    10  func TestInitProducerIDRequest(t *testing.T) {
    11  	for _, version := range []int16{0, 1, 2} {
    12  		prototest.TestRequest(t, version, &initproducerid.Request{
    13  			TransactionalID:      "transactional-id-0",
    14  			TransactionTimeoutMs: 1000,
    15  		})
    16  	}
    17  
    18  	// Version 2 added:
    19  	// ProducerID
    20  	// ProducerEpoch
    21  	for _, version := range []int16{3, 4} {
    22  		prototest.TestRequest(t, version, &initproducerid.Request{
    23  			TransactionalID:      "transactional-id-0",
    24  			TransactionTimeoutMs: 1000,
    25  			ProducerID:           10,
    26  			ProducerEpoch:        5,
    27  		})
    28  	}
    29  }
    30  
    31  func TestInitProducerIDResponse(t *testing.T) {
    32  	for _, version := range []int16{0, 1, 2, 3, 4} {
    33  		prototest.TestResponse(t, version, &initproducerid.Response{
    34  			ThrottleTimeMs: 1000,
    35  			ErrorCode:      9,
    36  			ProducerID:     10,
    37  			ProducerEpoch:  1000,
    38  		})
    39  	}
    40  }