(t *testing.T)
| 232 | } |
| 233 | |
| 234 | func TestUpdateGoldenFiles(t *testing.T) { |
| 235 | t.Parallel() |
| 236 | if !*updateGoldenFiles { |
| 237 | t.Skip("Run with -update to update golden files") |
| 238 | } |
| 239 | |
| 240 | helmPath := lookupHelm(t) |
| 241 | err := updateHelmDependencies(t, helmPath, "..") |
| 242 | require.NoError(t, err, "failed to build Helm dependencies") |
| 243 | |
| 244 | for _, tc := range testCases { |
| 245 | if tc.expectedError != "" { |
| 246 | t.Logf("skipping test case %q with render error", tc.name) |
| 247 | continue |
| 248 | } |
| 249 | |
| 250 | for _, ns := range namespaces { |
| 251 | tc.namespace = ns |
| 252 | |
| 253 | valuesPath := tc.valuesFilePath() |
| 254 | templateOutput, err := runHelmTemplate(t, helmPath, "..", valuesPath, tc.namespace) |
| 255 | if err != nil { |
| 256 | t.Logf("error running `helm template -f %q`: %v", valuesPath, err) |
| 257 | t.Logf("output: %s", templateOutput) |
| 258 | } |
| 259 | require.NoError(t, err, "failed to run `helm template -f %q`", valuesPath) |
| 260 | |
| 261 | goldenFilePath := tc.goldenFilePath() |
| 262 | err = os.WriteFile(goldenFilePath, []byte(templateOutput), 0o644) // nolint:gosec |
| 263 | require.NoError(t, err, "failed to write golden file %q", goldenFilePath) |
| 264 | } |
| 265 | } |
| 266 | t.Log("Golden files updated. Please review the changes and commit them.") |
| 267 | } |
| 268 | |
| 269 | // updateHelmDependencies runs `helm dependency update .` on the given chartDir. |
| 270 | func updateHelmDependencies(t testing.TB, helmPath, chartDir string) error { |
nothing calls this directly
no test coverage detected