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

Function TestUpdateGoldenFiles

helm/provisioner/tests/chart_test.go:180–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func 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.
216func 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