github.com/rbisecke/kafka-go@v0.4.27/protocol/createpartitions/createpartitions_test.go (about) 1 package createpartitions_test 2 3 import ( 4 "testing" 5 6 "github.com/rbisecke/kafka-go/protocol/createpartitions" 7 "github.com/rbisecke/kafka-go/protocol/prototest" 8 ) 9 10 const ( 11 v0 = 0 12 v1 = 1 13 ) 14 15 func TestCreatePartitionsRequest(t *testing.T) { 16 prototest.TestRequest(t, v0, &createpartitions.Request{ 17 Topics: []createpartitions.RequestTopic{ 18 { 19 Name: "foo", 20 Count: 1, 21 Assignments: []createpartitions.RequestAssignment{ 22 { 23 BrokerIDs: []int32{1, 2, 3}, 24 }, 25 }, 26 }, 27 }, 28 TimeoutMs: 500, 29 ValidateOnly: false, 30 }) 31 32 prototest.TestRequest(t, v1, &createpartitions.Request{ 33 Topics: []createpartitions.RequestTopic{ 34 { 35 Name: "foo", 36 Count: 1, 37 Assignments: []createpartitions.RequestAssignment{ 38 { 39 BrokerIDs: []int32{1, 2, 3}, 40 }, 41 }, 42 }, 43 }, 44 TimeoutMs: 500, 45 ValidateOnly: false, 46 }) 47 } 48 49 func TestCreatePartitionsResponse(t *testing.T) { 50 prototest.TestResponse(t, v0, &createpartitions.Response{ 51 ThrottleTimeMs: 500, 52 Results: []createpartitions.ResponseResult{ 53 { 54 Name: "foo", 55 ErrorCode: 1, 56 ErrorMessage: "foo", 57 }, 58 }, 59 }) 60 61 prototest.TestResponse(t, v1, &createpartitions.Response{ 62 ThrottleTimeMs: 500, 63 Results: []createpartitions.ResponseResult{ 64 { 65 Name: "foo", 66 ErrorCode: 1, 67 ErrorMessage: "foo", 68 }, 69 }, 70 }) 71 }