Skip to content

Commit 6128cdd

Browse files
authored
Make helm_template_test report all the errors before failing. (#229)
# Description Address #227 by processing all the test pattern and only invoking `log.Fatal` at the end if there was an error. ## Testing I hacked in some extra (failing) test cases on an existing test case. I didn't find any unit test test that check that failure modes for `helm_template_test` so I didn't bother including my test cases in this PR.
1 parent 87bcfd8 commit 6128cdd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

helm/private/runner/runner.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,23 +203,34 @@ func main() {
203203
}
204204

205205
templates := parseHelmOutput(test_stream.String())
206+
failed := false
206207
for templatePath, testPatterns := range patterns {
207208
content, found := templates[templatePath]
208209
if !found {
209-
log.Fatalf("Template not found in the helm chart: %s", templatePath)
210+
failed = true
211+
log.Printf("Template not found in the helm chart: %s", templatePath)
212+
continue
210213
}
211214

212215
for _, pattern := range testPatterns {
213216
regex, err := regexp.Compile(pattern)
214217
if err != nil {
215-
log.Fatal("Error compiling regex:", err)
218+
failed = true
219+
log.Print("Error compiling regex:", err)
220+
continue
216221
}
217222

218223
if !regex.MatchString(content) {
219-
log.Fatalf("Error: The file `%s` does not contain the pattern:\n```\n%s\n```", templatePath, pattern)
224+
failed = true
225+
log.Printf("Error: The file `%s` does not contain the pattern:\n```\n%s\n```", templatePath, pattern)
226+
continue
220227
}
221228
}
222229
}
230+
231+
if failed {
232+
log.Fatalf("Failed")
233+
}
223234
}
224235
}
225236

0 commit comments

Comments
 (0)