-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7941729
commit 44e849a
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package sarama | ||
|
||
import "testing" | ||
|
||
var ( | ||
joinGroupRequestNoProtocols = []byte{ | ||
0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p', // Group ID | ||
0, 0, 0, 100, // Session timeout | ||
0, 0, // Member ID | ||
0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r', // Protocol Type | ||
0, 0, 0, 0, // 0 protocol groups | ||
} | ||
|
||
joinGroupRequestOneProtocol = []byte{ | ||
0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p', // Group ID | ||
0, 0, 0, 100, // Session timeout | ||
0, 11, 'O', 'n', 'e', 'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', // Member ID | ||
0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r', // Protocol Type | ||
0, 0, 0, 1, // 1 group protocol | ||
0, 3, 'o', 'n', 'e', // Protocol name | ||
0, 0, 0, 3, 0x01, 0x02, 0x03, // protocol metadata | ||
} | ||
|
||
joinGroupRequestTwoProtocols = []byte{ | ||
0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p', // Group ID | ||
0, 0, 0, 100, // Session timeout | ||
0, 12, 'T', 'w', 'o', 'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', 's', // Member ID | ||
0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r', // Protocol Type | ||
0, 0, 0, 2, // 2 group protocol | ||
0, 3, 't', 'w', 'o', // Protocol name | ||
0, 0, 0, 3, 0x04, 0x05, 0x06, // protocol metadata | ||
0, 3, 'o', 'n', 'e', // Protocol name | ||
0, 0, 0, 3, 0x01, 0x02, 0x03, // protocol metadata | ||
} | ||
) | ||
|
||
func TestJoinGroupRequest(t *testing.T) { | ||
var request *JoinGroupRequest | ||
|
||
request = new(JoinGroupRequest) | ||
request.GroupId = "TestGroup" | ||
request.SessionTimeout = 100 | ||
request.ProtocolType = "consumer" | ||
testRequest(t, "no protocols", request, joinGroupRequestNoProtocols) | ||
|
||
request = new(JoinGroupRequest) | ||
request.GroupId = "TestGroup" | ||
request.SessionTimeout = 100 | ||
request.MemberId = "OneProtocol" | ||
request.ProtocolType = "consumer" | ||
request.AddGroupProtocol("one", []byte{0x01, 0x02, 0x03}) | ||
testRequest(t, "one protocol", request, joinGroupRequestOneProtocol) | ||
|
||
request = new(JoinGroupRequest) | ||
request.GroupId = "TestGroup" | ||
request.SessionTimeout = 100 | ||
request.MemberId = "TwoProtocols" | ||
request.ProtocolType = "consumer" | ||
request.AddGroupProtocol("one", []byte{0x01, 0x02, 0x03}) | ||
request.AddGroupProtocol("two", []byte{0x04, 0x05, 0x06}) | ||
testRequest(t, "two protocols", request, joinGroupRequestTwoProtocols) | ||
} |