123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package sarama
- import "testing"
- var (
- joinGroupRequestNoProtocols = []byte{
- 0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p',
- 0, 0, 0, 100,
- 0, 0,
- 0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r',
- 0, 0, 0, 0,
- }
- joinGroupRequestOneProtocol = []byte{
- 0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p',
- 0, 0, 0, 100,
- 0, 11, 'O', 'n', 'e', 'P', 'r', 'o', 't', 'o', 'c', 'o', 'l',
- 0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r',
- 0, 0, 0, 1,
- 0, 3, 'o', 'n', 'e',
- 0, 0, 0, 3, 0x01, 0x02, 0x03,
- }
- )
- func TestJoinGroupRequest(t *testing.T) {
- request := new(JoinGroupRequest)
- request.GroupId = "TestGroup"
- request.SessionTimeout = 100
- request.ProtocolType = "consumer"
- testRequest(t, "no protocols", request, joinGroupRequestNoProtocols)
- }
- func TestJoinGroupRequestOneProtocol(t *testing.T) {
- request := new(JoinGroupRequest)
- request.GroupId = "TestGroup"
- request.SessionTimeout = 100
- request.MemberId = "OneProtocol"
- request.ProtocolType = "consumer"
- request.AddGroupProtocol("one", []byte{0x01, 0x02, 0x03})
- packet := testRequestEncode(t, "one protocol", request, joinGroupRequestOneProtocol)
- request.GroupProtocols = make(map[string][]byte)
- request.GroupProtocols["one"] = []byte{0x01, 0x02, 0x03}
- testRequestDecode(t, "one protocol", request, packet)
- }
- func TestJoinGroupRequestDeprecatedEncode(t *testing.T) {
- request := new(JoinGroupRequest)
- request.GroupId = "TestGroup"
- request.SessionTimeout = 100
- request.MemberId = "OneProtocol"
- request.ProtocolType = "consumer"
- request.GroupProtocols = make(map[string][]byte)
- request.GroupProtocols["one"] = []byte{0x01, 0x02, 0x03}
- packet := testRequestEncode(t, "one protocol", request, joinGroupRequestOneProtocol)
- request.AddGroupProtocol("one", []byte{0x01, 0x02, 0x03})
- testRequestDecode(t, "one protocol", request, packet)
- }
|