(t *testing.T)
| 224 | } |
| 225 | |
| 226 | func TestRoundRobinAssignGroups(t *testing.T) { |
| 227 | newPartitions := func(partitionCount int, topics ...string) []Partition { |
| 228 | partitions := make([]Partition, 0, len(topics)*partitionCount) |
| 229 | for _, topic := range topics { |
| 230 | for partition := 0; partition < partitionCount; partition++ { |
| 231 | partitions = append(partitions, Partition{ |
| 232 | Topic: topic, |
| 233 | ID: partition, |
| 234 | }) |
| 235 | } |
| 236 | } |
| 237 | return partitions |
| 238 | } |
| 239 | |
| 240 | tests := map[string]struct { |
| 241 | Members []GroupMember |
| 242 | Partitions []Partition |
| 243 | Expected GroupMemberAssignments |
| 244 | }{ |
| 245 | "empty": { |
| 246 | Expected: GroupMemberAssignments{}, |
| 247 | }, |
| 248 | "one member, one topic, one partition": { |
| 249 | Members: []GroupMember{ |
| 250 | { |
| 251 | ID: "a", |
| 252 | Topics: []string{"topic-1"}, |
| 253 | }, |
| 254 | }, |
| 255 | Partitions: newPartitions(1, "topic-1"), |
| 256 | Expected: GroupMemberAssignments{ |
| 257 | "a": map[string][]int{ |
| 258 | "topic-1": {0}, |
| 259 | }, |
| 260 | }, |
| 261 | }, |
| 262 | "one member, one topic, multiple partitions": { |
| 263 | Members: []GroupMember{ |
| 264 | { |
| 265 | ID: "a", |
| 266 | Topics: []string{"topic-1"}, |
| 267 | }, |
| 268 | }, |
| 269 | Partitions: newPartitions(3, "topic-1"), |
| 270 | Expected: GroupMemberAssignments{ |
| 271 | "a": map[string][]int{ |
| 272 | "topic-1": {0, 1, 2}, |
| 273 | }, |
| 274 | }, |
| 275 | }, |
| 276 | "multiple members, one topic, one partition": { |
| 277 | Members: []GroupMember{ |
| 278 | { |
| 279 | ID: "a", |
| 280 | Topics: []string{"topic-1"}, |
| 281 | }, |
| 282 | { |
| 283 | ID: "b", |
nothing calls this directly
no test coverage detected