1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package sarama
- import (
- "testing"
- "time"
- )
- func TestFindCoordinatorResponse(t *testing.T) {
- errMsg := "kaboom"
- for _, tc := range []struct {
- desc string
- response *FindCoordinatorResponse
- encoded []byte
- }{{
- desc: "version 0 - no error",
- response: &FindCoordinatorResponse{
- Version: 0,
- Err: ErrNoError,
- Coordinator: &Broker{
- id: 7,
- addr: "host:9092",
- },
- },
- encoded: []byte{
- 0, 0,
- 0, 0, 0, 7,
- 0, 4, 'h', 'o', 's', 't',
- 0, 0, 35, 132,
- },
- }, {
- desc: "version 1 - no error",
- response: &FindCoordinatorResponse{
- Version: 1,
- ThrottleTime: 100 * time.Millisecond,
- Err: ErrNoError,
- Coordinator: &Broker{
- id: 7,
- addr: "host:9092",
- },
- },
- encoded: []byte{
- 0, 0, 0, 100,
- 0, 0,
- 255, 255,
- 0, 0, 0, 7,
- 0, 4, 'h', 'o', 's', 't',
- 0, 0, 35, 132,
- },
- }, {
- desc: "version 0 - error",
- response: &FindCoordinatorResponse{
- Version: 0,
- Err: ErrConsumerCoordinatorNotAvailable,
- Coordinator: NoNode,
- },
- encoded: []byte{
- 0, 15,
- 255, 255, 255, 255,
- 0, 0,
- 255, 255, 255, 255,
- },
- }, {
- desc: "version 1 - error",
- response: &FindCoordinatorResponse{
- Version: 1,
- ThrottleTime: 100 * time.Millisecond,
- Err: ErrConsumerCoordinatorNotAvailable,
- ErrMsg: &errMsg,
- Coordinator: NoNode,
- },
- encoded: []byte{
- 0, 0, 0, 100,
- 0, 15,
- 0, 6, 'k', 'a', 'b', 'o', 'o', 'm',
- 255, 255, 255, 255,
- 0, 0,
- 255, 255, 255, 255,
- },
- }} {
- testResponse(t, tc.desc, tc.response, tc.encoded)
- }
- }
|