MCPcopy Create free account
hub / github.com/cozystack/talm / renderGenericExpectError

Function renderGenericExpectError

pkg/engine/render_test.go:6916–6947  ·  view source on GitHub ↗

renderGenericExpectError is the generic-preset counterpart of renderCozystackExpectError. Used by mirror tests that pin the same error-message contract on the generic chart.

(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any, talosVersion ...string)

Source from the content-addressed store, hash-verified

6914// renderCozystackExpectError. Used by mirror tests that pin the
6915// same error-message contract on the generic chart.
6916func renderGenericExpectError(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any, talosVersion ...string) error {
6917 t.Helper()
6918 origLookup := helmEngine.LookupFunc
6919 t.Cleanup(func() { helmEngine.LookupFunc = origLookup })
6920 helmEngine.LookupFunc = lookup
6921
6922 chrt, err := loader.LoadDir("../../charts/generic")
6923 if err != nil {
6924 t.Fatalf("load chart: %v", err)
6925 }
6926 values := cloneValues(chrt.Values)
6927 if v, _ := values["endpoint"].(string); v == "" {
6928 values["endpoint"] = testEndpoint
6929 }
6930 if arr, ok := values["advertisedSubnets"].([]any); !ok || len(arr) == 0 {
6931 values["advertisedSubnets"] = []any{testAdvertisedSubnet}
6932 }
6933 maps.Copy(values, overrides)
6934
6935 version := "v1.12"
6936 if len(talosVersion) > 0 && talosVersion[0] != "" {
6937 version = talosVersion[0]
6938 }
6939
6940 eng := helmEngine.Engine{}
6941 _, err = eng.Render(chrt, chartutil.Values{
6942 "Values": values,
6943 "TalosVersion": version,
6944 })
6945
6946 return err //nolint:wrapcheck // surfacing the render error verbatim is the whole point of this helper
6947}
6948
6949// renderGenericWith is the generic-preset counterpart of renderCozystackWith.
6950func renderGenericWith(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any) string {

Calls 2

RenderMethod · 0.95
cloneValuesFunction · 0.85

Tested by

no test coverage detected