cmd/cloner: handle named slices as map values (#20387)
Previously cloner only handled literal slices for values, like `map[string][]int`. This adds support for named types with an underlying type of slice, like `map[string]IntSlice` with `type IntSlice []int`. Updates tailscale/corp#44077 Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
@@ -283,3 +283,13 @@ func TestDeeplyNestedMap(t *testing.T) {
|
||||
t.Errorf("Clone() aliased FourLevels map: new nested key appeared in original")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapWithNamedSliceValues(t *testing.T) {
|
||||
orig := &clonerex.MapWithNamedSliceValues{
|
||||
M: map[string]clonerex.NamedSlice{"k": {"foo", "bar"}},
|
||||
}
|
||||
cloned := orig.Clone()
|
||||
if diff := cmp.Diff(orig, cloned); diff != "" {
|
||||
t.Errorf("Clone() mismatch (-orig +cloned):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user