(t *testing.T)
| 74 | } |
| 75 | |
| 76 | func 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…