(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func TestRangeAssignGroups(t *testing.T) { |
| 79 | newMeta := func(memberID string, topics ...string) GroupMember { |
| 80 | return GroupMember{ |
| 81 | ID: memberID, |
| 82 | Topics: topics, |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | newPartitions := func(partitionCount int, topics ...string) []Partition { |
| 87 | partitions := make([]Partition, 0, len(topics)*partitionCount) |
| 88 | for _, topic := range topics { |
| 89 | for partition := 0; partition < partitionCount; partition++ { |
| 90 | partitions = append(partitions, Partition{ |
| 91 | Topic: topic, |
| 92 | ID: partition, |
| 93 | }) |
| 94 | } |
| 95 | } |
| 96 | return partitions |
| 97 | } |
| 98 | |
| 99 | tests := map[string]struct { |
| 100 | Members []GroupMember |
| 101 | Partitions []Partition |
| 102 | Expected GroupMemberAssignments |
| 103 | }{ |
| 104 | "empty": { |
| 105 | Expected: GroupMemberAssignments{}, |
| 106 | }, |
| 107 | "one member, one topic, one partition": { |
| 108 | Members: []GroupMember{ |
| 109 | newMeta("a", "topic-1"), |
| 110 | }, |
| 111 | Partitions: newPartitions(1, "topic-1"), |
| 112 | Expected: GroupMemberAssignments{ |
| 113 | "a": map[string][]int{ |
| 114 | "topic-1": {0}, |
| 115 | }, |
| 116 | }, |
| 117 | }, |
| 118 | "one member, one topic, multiple partitions": { |
| 119 | Members: []GroupMember{ |
| 120 | newMeta("a", "topic-1"), |
| 121 | }, |
| 122 | Partitions: newPartitions(3, "topic-1"), |
| 123 | Expected: GroupMemberAssignments{ |
| 124 | "a": map[string][]int{ |
| 125 | "topic-1": {0, 1, 2}, |
| 126 | }, |
| 127 | }, |
| 128 | }, |
| 129 | "multiple members, one topic, one partition": { |
| 130 | Members: []GroupMember{ |
| 131 | newMeta("a", "topic-1"), |
| 132 | newMeta("b", "topic-1"), |
| 133 | }, |
| 134 | Partitions: newPartitions(1, "topic-1"), |
| 135 | Expected: GroupMemberAssignments{ |
nothing calls this directly
no test coverage detected