github.com/hoveychen/kafka-go@v0.4.42/protocol/heartbeat/heartbeat_test.go (about) 1 package heartbeat_test 2 3 import ( 4 "testing" 5 6 "github.com/hoveychen/kafka-go/protocol/heartbeat" 7 "github.com/hoveychen/kafka-go/protocol/prototest" 8 ) 9 10 func TestHeartbeatRequest(t *testing.T) { 11 // Versions 0-3 have all the same fields. 12 for _, version := range []int16{0, 1, 2, 3} { 13 prototest.TestRequest(t, version, &heartbeat.Request{ 14 GroupID: "group-1", 15 GenerationID: 1, 16 MemberID: "member-1", 17 }) 18 } 19 20 for _, version := range []int16{4} { 21 prototest.TestRequest(t, version, &heartbeat.Request{ 22 GroupID: "group-2", 23 GenerationID: 10, 24 MemberID: "member-2", 25 GroupInstanceID: "instace-1", 26 }) 27 } 28 } 29 30 func TestHeartbeatResponse(t *testing.T) { 31 for _, version := range []int16{0} { 32 prototest.TestResponse(t, version, &heartbeat.Response{ 33 ErrorCode: 4, 34 }) 35 } 36 37 // Versions 1-4 have all the same fields. 38 for _, version := range []int16{1, 2, 3, 4} { 39 prototest.TestResponse(t, version, &heartbeat.Response{ 40 ErrorCode: 4, 41 ThrottleTimeMs: 10, 42 }) 43 } 44 }