MCPcopy
hub / github.com/helm/helm / TestCreateCmdChartAPIVersionV2

Function TestCreateCmdChartAPIVersionV2

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

Source from the content-addressed store, hash-verified

202}
203
204func TestCreateCmdChartAPIVersionV2(t *testing.T) {
205 t.Chdir(t.TempDir())
206 ensure.HelmHome(t)
207 cname := "testchart"
208
209 // Run a create with explicit v2
210 if _, _, err := executeActionCommand("create --chart-api-version=v2 " + cname); err != nil {
211 t.Fatalf("Failed to run create: %s", err)
212 }
213
214 // Test that the chart is there
215 if fi, err := os.Stat(cname); err != nil {
216 t.Fatalf("no chart directory: %s", err)
217 } else if !fi.IsDir() {
218 t.Fatal("chart is not directory")
219 }
220
221 c, err := chartloader.LoadDir(cname)
222 if err != nil {
223 t.Fatal(err)
224 }
225
226 acc, err := chart.NewAccessor(c)
227 if err != nil {
228 t.Fatal(err)
229 }
230
231 if acc.Name() != cname {
232 t.Errorf("Expected %q name, got %q", cname, acc.Name())
233 }
234 metadata := acc.MetadataAsMap()
235 apiVersion, ok := metadata["APIVersion"].(string)
236 if !ok {
237 t.Fatal("APIVersion not found in metadata")
238 }
239 if apiVersion != chartv2.APIVersionV2 {
240 t.Errorf("Wrong API version: expected %q, got %q", chartv2.APIVersionV2, apiVersion)
241 }
242}
243
244func TestCreateCmdChartAPIVersionV3(t *testing.T) {
245 t.Chdir(t.TempDir())

Callers

nothing calls this directly

Calls 6

NameMethod · 0.95
MetadataAsMapMethod · 0.95
HelmHomeFunction · 0.92
executeActionCommandFunction · 0.85
FatalfMethod · 0.80
FatalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…