MCPcopy
hub / github.com/helm/helm / TestCreateCmdChartAPIVersionV3

Function TestCreateCmdChartAPIVersionV3

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

Source from the content-addressed store, hash-verified

242}
243
244func TestCreateCmdChartAPIVersionV3(t *testing.T) {
245 t.Chdir(t.TempDir())
246 ensure.HelmHome(t)
247 t.Setenv(string(gates.ChartV3), "1")
248 cname := "testchart"
249
250 // Run a create with v3
251 if _, _, err := executeActionCommand("create --chart-api-version=v3 " + cname); err != nil {
252 t.Fatalf("Failed to run create: %s", err)
253 }
254
255 // Test that the chart is there
256 if fi, err := os.Stat(cname); err != nil {
257 t.Fatalf("no chart directory: %s", err)
258 } else if !fi.IsDir() {
259 t.Fatal("chart is not directory")
260 }
261
262 c, err := chartloader.LoadDir(cname)
263 if err != nil {
264 t.Fatal(err)
265 }
266
267 acc, err := chart.NewAccessor(c)
268 if err != nil {
269 t.Fatal(err)
270 }
271
272 if acc.Name() != cname {
273 t.Errorf("Expected %q name, got %q", cname, acc.Name())
274 }
275 metadata := acc.MetadataAsMap()
276 apiVersion, ok := metadata["APIVersion"].(string)
277 if !ok {
278 t.Fatal("APIVersion not found in metadata")
279 }
280 if apiVersion != chartv3.APIVersionV3 {
281 t.Errorf("Wrong API version: expected %q, got %q", chartv3.APIVersionV3, apiVersion)
282 }
283}
284
285func TestCreateCmdInvalidChartAPIVersion(t *testing.T) {
286 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…