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

Function createTestChart

pkg/engine/render_test.go:568–590  ·  view source on GitHub ↗

createTestChart creates a minimal Helm chart in a temp directory with the given template content. Returns the chart root path.

(t *testing.T, chartName, templateName, templateContent string)

Source from the content-addressed store, hash-verified

566// createTestChart creates a minimal Helm chart in a temp directory with the
567// given template content. Returns the chart root path.
568func createTestChart(t *testing.T, chartName, templateName, templateContent string) string {
569 t.Helper()
570 root := t.TempDir()
571
572 chartYAML := "apiVersion: v2\nname: " + chartName + "\ntype: application\nversion: 0.1.0\n"
573 if err := os.WriteFile(filepath.Join(root, "Chart.yaml"), []byte(chartYAML), 0o644); err != nil {
574 t.Fatalf("write Chart.yaml: %v", err)
575 }
576
577 if err := os.WriteFile(filepath.Join(root, "values.yaml"), []byte("{}\n"), 0o644); err != nil {
578 t.Fatalf("write values.yaml: %v", err)
579 }
580
581 templatesDir := filepath.Join(root, "templates")
582 if err := os.MkdirAll(templatesDir, 0o755); err != nil {
583 t.Fatalf("mkdir templates: %v", err)
584 }
585 if err := os.WriteFile(filepath.Join(templatesDir, templateName), []byte(templateContent), 0o644); err != nil {
586 t.Fatalf("write template: %v", err)
587 }
588
589 return root
590}
591
592// TestLookupOfflineProducesEmptyInterface is a regression test for the bug
593// where `talm apply` rendered templates offline, causing lookup() to return

Calls

no outgoing calls

Tested by

no test coverage detected