File: initproducerid_test.go

package info (click to toggle)
golang-github-segmentio-kafka-go 0.4.49%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,292 kB
  • sloc: sh: 17; makefile: 10
file content (40 lines) | stat: -rw-r--r-- 969 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package initproducerid_test

import (
	"testing"

	"github.com/segmentio/kafka-go/protocol/initproducerid"
	"github.com/segmentio/kafka-go/protocol/prototest"
)

func TestInitProducerIDRequest(t *testing.T) {
	for _, version := range []int16{0, 1, 2} {
		prototest.TestRequest(t, version, &initproducerid.Request{
			TransactionalID:      "transactional-id-0",
			TransactionTimeoutMs: 1000,
		})
	}

	// Version 2 added:
	// ProducerID
	// ProducerEpoch
	for _, version := range []int16{3, 4} {
		prototest.TestRequest(t, version, &initproducerid.Request{
			TransactionalID:      "transactional-id-0",
			TransactionTimeoutMs: 1000,
			ProducerID:           10,
			ProducerEpoch:        5,
		})
	}
}

func TestInitProducerIDResponse(t *testing.T) {
	for _, version := range []int16{0, 1, 2, 3, 4} {
		prototest.TestResponse(t, version, &initproducerid.Response{
			ThrottleTimeMs: 1000,
			ErrorCode:      9,
			ProducerID:     10,
			ProducerEpoch:  1000,
		})
	}
}