(t *testing.T)
| 134 | } |
| 135 | |
| 136 | func TestGroupE2E(t *testing.T) { |
| 137 | testHierarchy := map[string]map[string][]string{ |
| 138 | "p0": { |
| 139 | "wt0": {"addr0", "addr1"}, |
| 140 | "wt1": {"addr2", "addr3"}, |
| 141 | }, |
| 142 | "p1": { |
| 143 | "wt10": {"addr10", "addr11"}, |
| 144 | "wt11": {"addr12", "addr13"}, |
| 145 | }, |
| 146 | } |
| 147 | |
| 148 | var epsWithHierarchy []resolver.Endpoint |
| 149 | for p, wts := range testHierarchy { |
| 150 | path1 := []string{p} |
| 151 | for wt, addrs := range wts { |
| 152 | path2 := append([]string(nil), path1...) |
| 153 | path2 = append(path2, wt) |
| 154 | for _, addr := range addrs { |
| 155 | a := hierarchy.SetInEndpoint(resolver.Endpoint{Addresses: []resolver.Address{{Addr: addr}}}, path2) |
| 156 | epsWithHierarchy = append(epsWithHierarchy, a) |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | gotHierarchy := make(map[string]map[string][]string) |
| 162 | for p1, wts := range hierarchy.Group(epsWithHierarchy) { |
| 163 | gotHierarchy[p1] = make(map[string][]string) |
| 164 | for p2, eps := range hierarchy.Group(wts) { |
| 165 | for _, ep := range eps { |
| 166 | gotHierarchy[p1][p2] = append(gotHierarchy[p1][p2], ep.Addresses[0].Addr) |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | if !cmp.Equal(gotHierarchy, testHierarchy) { |
| 172 | t.Errorf("diff: %v", cmp.Diff(gotHierarchy, testHierarchy)) |
| 173 | } |
| 174 | } |
nothing calls this directly
no test coverage detected