cloneValues returns a recursive deep copy of the chart values map. maps.Copy is a shallow copy — mutating a nested map or slice in a test would leak into chrt.Values and corrupt subsequent renders. Since chart values consist only of maps, slices, and primitives, a small switch + recursion suffices;
(src map[string]any)
| 49 | // Since chart values consist only of maps, slices, and primitives, |
| 50 | // a small switch + recursion suffices; no external dep needed. |
| 51 | func cloneValues(src map[string]any) map[string]any { |
| 52 | dst := make(map[string]any, len(src)) |
| 53 | for k, v := range src { |
| 54 | dst[k] = deepClone(v) |
| 55 | } |
| 56 | return dst |
| 57 | } |
| 58 | |
| 59 | func deepClone(v any) any { |
| 60 | switch x := v.(type) { |
no test coverage detected