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)
| 257 | // |
| 258 | // See https://github.com/helm/helm/issues/7483 |
| 259 | func 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 | |
| 300 | func TestValidateMatchSelector(t *testing.T) { |
| 301 | md := &k8sYamlStruct{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…