(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestFindCoordinatorResponse(t *testing.T) { |
| 11 | errMsg := "kaboom" |
| 12 | |
| 13 | for _, tc := range []struct { |
| 14 | desc string |
| 15 | response *FindCoordinatorResponse |
| 16 | encoded []byte |
| 17 | }{{ |
| 18 | desc: "version 0 - no error", |
| 19 | response: &FindCoordinatorResponse{ |
| 20 | Version: 0, |
| 21 | Err: ErrNoError, |
| 22 | Coordinator: &Broker{ |
| 23 | id: 7, |
| 24 | addr: "host:9092", |
| 25 | }, |
| 26 | }, |
| 27 | encoded: []byte{ |
| 28 | 0, 0, // Err |
| 29 | 0, 0, 0, 7, // Coordinator.ID |
| 30 | 0, 4, 'h', 'o', 's', 't', // Coordinator.Host |
| 31 | 0, 0, 35, 132, // Coordinator.Port |
| 32 | }, |
| 33 | }, { |
| 34 | desc: "version 1 - no error", |
| 35 | response: &FindCoordinatorResponse{ |
| 36 | Version: 1, |
| 37 | ThrottleTime: 100 * time.Millisecond, |
| 38 | Err: ErrNoError, |
| 39 | Coordinator: &Broker{ |
| 40 | id: 7, |
| 41 | addr: "host:9092", |
| 42 | }, |
| 43 | }, |
| 44 | encoded: []byte{ |
| 45 | 0, 0, 0, 100, // ThrottleTime |
| 46 | 0, 0, // Err |
| 47 | 255, 255, // ErrMsg: empty |
| 48 | 0, 0, 0, 7, // Coordinator.ID |
| 49 | 0, 4, 'h', 'o', 's', 't', // Coordinator.Host |
| 50 | 0, 0, 35, 132, // Coordinator.Port |
| 51 | }, |
| 52 | }, { |
| 53 | desc: "version 0 - error", |
| 54 | response: &FindCoordinatorResponse{ |
| 55 | Version: 0, |
| 56 | Err: ErrConsumerCoordinatorNotAvailable, |
| 57 | Coordinator: NoNode, |
| 58 | }, |
| 59 | encoded: []byte{ |
| 60 | 0, 15, // Err |
| 61 | 255, 255, 255, 255, // Coordinator.ID: -1 |
| 62 | 0, 0, // Coordinator.Host: "" |
| 63 | 255, 255, 255, 255, // Coordinator.Port: -1 |
| 64 | }, |
| 65 | }, { |
| 66 | desc: "version 1 - error", |
| 67 | response: &FindCoordinatorResponse{ |
nothing calls this directly
no test coverage detected