renderCozystackWith renders the cozystack controlplane template against the supplied LookupFunc and values overrides, returning the final template output or failing the test. Mirrors the pattern used by the existing TestMultiDoc* suites.
(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any)
| 6832 | // final template output or failing the test. Mirrors the pattern used |
| 6833 | // by the existing TestMultiDoc* suites. |
| 6834 | func renderCozystackWith(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any) string { |
| 6835 | t.Helper() |
| 6836 | origLookup := helmEngine.LookupFunc |
| 6837 | t.Cleanup(func() { helmEngine.LookupFunc = origLookup }) |
| 6838 | helmEngine.LookupFunc = lookup |
| 6839 | |
| 6840 | chrt, err := loader.LoadDir("../../charts/cozystack") |
| 6841 | if err != nil { |
| 6842 | t.Fatalf("load chart: %v", err) |
| 6843 | } |
| 6844 | // Deep-copy chart values so mutations in this helper (or in the |
| 6845 | // caller's overrides) never leak into chrt.Values and corrupt |
| 6846 | // subsequent renders. |
| 6847 | values := cloneValues(chrt.Values) |
| 6848 | // Default endpoint for tests that don't exercise the required guard. |
| 6849 | // Caller overrides via the overrides map if it wants to trigger `required`. |
| 6850 | if v, _ := values["endpoint"].(string); v == "" { |
| 6851 | values["endpoint"] = testEndpoint |
| 6852 | } |
| 6853 | maps.Copy(values, overrides) |
| 6854 | |
| 6855 | eng := helmEngine.Engine{} |
| 6856 | out, err := eng.Render(chrt, chartutil.Values{ |
| 6857 | "Values": values, |
| 6858 | "TalosVersion": "v1.12", |
| 6859 | }) |
| 6860 | if err != nil { |
| 6861 | t.Fatalf("render: %v", err) |
| 6862 | } |
| 6863 | return out["cozystack/templates/controlplane.yaml"] |
| 6864 | } |
| 6865 | |
| 6866 | // renderCozystackExpectError mirrors renderCozystackWith but returns |
| 6867 | // the render error to the caller instead of t.Fatal'ing on it. Used |
no test coverage detected