MCPcopy Index your code
hub / github.com/coder/coder / TestUpdateGoldenFiles

Function TestUpdateGoldenFiles

helm/coder/tests/chart_test.go:234–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

232}
233
234func 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.
270func updateHelmDependencies(t testing.TB, helmPath, chartDir string) error {

Callers

nothing calls this directly

Calls 9

SkipMethod · 0.80
LogMethod · 0.80
lookupHelmFunction · 0.70
updateHelmDependenciesFunction · 0.70
runHelmTemplateFunction · 0.70
LogfMethod · 0.65
WriteFileMethod · 0.65
valuesFilePathMethod · 0.45
goldenFilePathMethod · 0.45

Tested by

no test coverage detected