@@ -85,6 +85,8 @@ func TestRenderChart(t *testing.T) {
85
85
86
86
// Ensure that Helm is available in $PATH
87
87
helmPath := lookupHelm (t )
88
+ err := updateHelmDependencies (t , helmPath , ".." )
89
+ require .NoError (t , err , "failed to build Helm dependencies" )
88
90
for _ , tc := range testCases {
89
91
tc := tc
90
92
t .Run (tc .name , func (t * testing.T ) {
@@ -144,6 +146,26 @@ func TestUpdateGoldenFiles(t *testing.T) {
144
146
t .Log ("Golden files updated. Please review the changes and commit them." )
145
147
}
146
148
149
+ // updateHelmDependencies runs `helm dependency update .` on the given chartDir.
150
+ func updateHelmDependencies (t testing.TB , helmPath , chartDir string ) error {
151
+ // Remove charts/ from chartDir if it exists.
152
+ err := os .RemoveAll (filepath .Join (chartDir , "charts" ))
153
+ if err != nil {
154
+ return xerrors .Errorf ("failed to remove charts/ directory: %w" , err )
155
+ }
156
+
157
+ // Regenerate the chart dependencies.
158
+ cmd := exec .Command (helmPath , "dependency" , "update" , "--skip-refresh" , "." )
159
+ cmd .Dir = chartDir
160
+ t .Logf ("exec command: %v" , cmd .Args )
161
+ out , err := cmd .CombinedOutput ()
162
+ if err != nil {
163
+ return xerrors .Errorf ("failed to run `helm dependency build`: %w\n output: %s" , err , out )
164
+ }
165
+
166
+ return nil
167
+ }
168
+
147
169
// runHelmTemplate runs helm template on the given chart with the given values and
148
170
// returns the raw output.
149
171
func runHelmTemplate (t testing.TB , helmPath , chartDir , valuesFilePath string ) (string , error ) {
0 commit comments