MCPcopy
hub / github.com/helm/helm / TestCreateStarterCmd

Function TestCreateStarterCmd

pkg/cmd/create_test.go:76–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestCreateStarterCmd(t *testing.T) {
77 tests := []struct {
78 name string
79 chartAPIVersion string
80 useAbsolutePath bool
81 expectedVersion string
82 }{
83 {
84 name: "v2 with relative starter path",
85 chartAPIVersion: "",
86 useAbsolutePath: false,
87 expectedVersion: chartv2.APIVersionV2,
88 },
89 {
90 name: "v2 with absolute starter path",
91 chartAPIVersion: "",
92 useAbsolutePath: true,
93 expectedVersion: chartv2.APIVersionV2,
94 },
95 {
96 name: "v3 with relative starter path",
97 chartAPIVersion: "v3",
98 useAbsolutePath: false,
99 expectedVersion: chartv3.APIVersionV3,
100 },
101 }
102
103 for _, tt := range tests {
104 t.Run(tt.name, func(t *testing.T) {
105 t.Chdir(t.TempDir())
106 ensure.HelmHome(t)
107 defer resetEnv()()
108
109 // Enable feature gate for v3 charts
110 if tt.chartAPIVersion == "v3" {
111 t.Setenv(string(gates.ChartV3), "1")
112 }
113
114 cname := "testchart"
115
116 // Create a starter using the appropriate chartutil
117 starterchart := helmpath.DataPath("starters")
118 os.MkdirAll(starterchart, 0o755)
119 var err error
120 var dest string
121 if tt.chartAPIVersion == "v3" {
122 dest, err = chartutilv3.Create("starterchart", starterchart)
123 } else {
124 dest, err = chartutil.Create("starterchart", starterchart)
125 }
126 if err != nil {
127 t.Fatalf("Could not create chart: %s", err)
128 }
129 t.Logf("Created %s", dest)
130
131 tplpath := filepath.Join(starterchart, "starterchart", "templates", "foo.tpl")
132 if err := os.WriteFile(tplpath, []byte("test"), 0o644); err != nil {
133 t.Fatalf("Could not write template: %s", err)

Callers

nothing calls this directly

Calls 14

NameMethod · 0.95
MetadataAsMapMethod · 0.95
TemplatesMethod · 0.95
HelmHomeFunction · 0.92
DataPathFunction · 0.92
executeActionCommandFunction · 0.85
FatalfMethod · 0.80
FatalMethod · 0.80
ContainsMethod · 0.80
resetEnvFunction · 0.70
RunMethod · 0.65
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…