MCPcopy
hub / github.com/helm/helm / TestStrictTemplateParsingMapError

Function TestStrictTemplateParsingMapError

pkg/chart/v2/lint/rules/template_test.go:259–298  ·  view source on GitHub ↗

TestStrictTemplateParsingMapError is a regression test. The template engine should not produce an error when a map in values.yaml does not contain all possible keys. See https://github.com/helm/helm/issues/7483

(t *testing.T)

Source from the content-addressed store, hash-verified

257//
258// See https://github.com/helm/helm/issues/7483
259func TestStrictTemplateParsingMapError(t *testing.T) {
260
261 ch := chart.Chart{
262 Metadata: &chart.Metadata{
263 Name: "regression7483",
264 APIVersion: "v2",
265 Version: "0.1.0",
266 },
267 Values: map[string]any{
268 "mymap": map[string]string{
269 "key1": "val1",
270 },
271 },
272 Templates: []*common.File{
273 {
274 Name: "templates/configmap.yaml",
275 ModTime: time.Now(),
276 Data: []byte(manifest),
277 },
278 },
279 }
280 dir := t.TempDir()
281 if err := chartutil.SaveDir(&ch, dir); err != nil {
282 t.Fatal(err)
283 }
284 linter := &support.Linter{
285 ChartDir: filepath.Join(dir, ch.Metadata.Name),
286 }
287 Templates(
288 linter,
289 namespace,
290 ch.Values,
291 TemplateLinterSkipSchemaValidation(false))
292 if len(linter.Messages) != 0 {
293 t.Errorf("expected zero messages, got %d", len(linter.Messages))
294 for i, msg := range linter.Messages {
295 t.Logf("Message %d: %q", i, msg)
296 }
297 }
298}
299
300func TestValidateMatchSelector(t *testing.T) {
301 md := &k8sYamlStruct{

Callers

nothing calls this directly

Calls 4

NowMethod · 0.80
FatalMethod · 0.80
TemplatesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…