(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func TestReaderAssignTopicPartitions(t *testing.T) { |
| 121 | conn := &mockCoordinator{ |
| 122 | readPartitionsFunc: func(...string) ([]Partition, error) { |
| 123 | return []Partition{ |
| 124 | { |
| 125 | Topic: "topic-1", |
| 126 | ID: 0, |
| 127 | }, |
| 128 | { |
| 129 | Topic: "topic-1", |
| 130 | ID: 1, |
| 131 | }, |
| 132 | { |
| 133 | Topic: "topic-1", |
| 134 | ID: 2, |
| 135 | }, |
| 136 | { |
| 137 | Topic: "topic-2", |
| 138 | ID: 0, |
| 139 | }, |
| 140 | }, nil |
| 141 | }, |
| 142 | } |
| 143 | |
| 144 | newJoinGroupResponse := func(topicsByMemberID map[string][]string) func(v apiVersion) joinGroupResponse { |
| 145 | return func(v apiVersion) joinGroupResponse { |
| 146 | resp := joinGroupResponse{ |
| 147 | v: v, |
| 148 | GroupProtocol: RoundRobinGroupBalancer{}.ProtocolName(), |
| 149 | } |
| 150 | |
| 151 | for memberID, topics := range topicsByMemberID { |
| 152 | resp.Members = append(resp.Members, joinGroupResponseMember{ |
| 153 | MemberID: memberID, |
| 154 | MemberMetadata: groupMetadata{ |
| 155 | Topics: topics, |
| 156 | }.bytes(), |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | return resp |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | testCases := map[string]struct { |
| 165 | MembersFunc func(v apiVersion) joinGroupResponse |
| 166 | Assignments GroupMemberAssignments |
| 167 | }{ |
| 168 | "nil": { |
| 169 | MembersFunc: newJoinGroupResponse(nil), |
| 170 | Assignments: GroupMemberAssignments{}, |
| 171 | }, |
| 172 | "one member, one topic": { |
| 173 | MembersFunc: newJoinGroupResponse(map[string][]string{ |
| 174 | "member-1": {"topic-1"}, |
| 175 | }), |
| 176 | Assignments: GroupMemberAssignments{ |
| 177 | "member-1": map[string][]int{ |
nothing calls this directly
no test coverage detected