(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestUpdateGoldenFiles(t *testing.T) { |
| 181 | t.Parallel() |
| 182 | if !*updateGoldenFiles { |
| 183 | t.Skip("Run with -update to update golden files") |
| 184 | } |
| 185 | |
| 186 | helmPath := lookupHelm(t) |
| 187 | err := updateHelmDependencies(t, helmPath, "..") |
| 188 | require.NoError(t, err, "failed to build Helm dependencies") |
| 189 | |
| 190 | for _, tc := range testCases { |
| 191 | if tc.expectedError != "" { |
| 192 | t.Logf("skipping test case %q with render error", tc.name) |
| 193 | continue |
| 194 | } |
| 195 | |
| 196 | for _, ns := range namespaces { |
| 197 | tc.namespace = ns |
| 198 | |
| 199 | valuesPath := tc.valuesFilePath() |
| 200 | templateOutput, err := runHelmTemplate(t, helmPath, "..", valuesPath, tc.namespace) |
| 201 | if err != nil { |
| 202 | t.Logf("error running `helm template -f %q`: %v", valuesPath, err) |
| 203 | t.Logf("output: %s", templateOutput) |
| 204 | } |
| 205 | require.NoError(t, err, "failed to run `helm template -f %q`", valuesPath) |
| 206 | |
| 207 | goldenFilePath := tc.goldenFilePath() |
| 208 | err = os.WriteFile(goldenFilePath, []byte(templateOutput), 0o644) // nolint:gosec |
| 209 | require.NoError(t, err, "failed to write golden file %q", goldenFilePath) |
| 210 | } |
| 211 | } |
| 212 | t.Log("Golden files updated. Please review the changes and commit them.") |
| 213 | } |
| 214 | |
| 215 | // updateHelmDependencies runs `helm dependency update .` on the given chartDir. |
| 216 | func updateHelmDependencies(t testing.TB, helmPath, chartDir string) error { |
nothing calls this directly
no test coverage detected