|
31 | 31 | import org.junit.jupiter.params.ParameterizedTest; |
32 | 32 | import org.junit.jupiter.params.provider.CsvSource; |
33 | 33 | import org.junit.jupiter.params.provider.ValueSource; |
| 34 | +import org.junitpioneer.jupiter.RetryingTest; |
34 | 35 | import org.mockito.Mockito; |
35 | 36 | import org.slf4j.event.Level; |
36 | 37 | import org.sonar.api.impl.utils.DefaultTempFolder; |
37 | 38 | import org.sonar.api.testfixtures.log.LogTesterJUnit5; |
38 | 39 | import org.sonar.iac.helm.protobuf.TemplateEvaluationResult; |
39 | 40 | import org.sonar.iac.helm.utils.ExecutableHelper; |
40 | 41 |
|
41 | | -import static org.assertj.core.api.Assertions.assertThat; |
42 | 42 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
43 | 43 | import static org.mockito.ArgumentMatchers.any; |
44 | 44 | import static org.mockito.Mockito.doNothing; |
@@ -73,19 +73,16 @@ static void cleanup() throws IOException { |
73 | 73 | FileUtils.deleteDirectory(tempDir); |
74 | 74 | } |
75 | 75 |
|
76 | | - @Test |
| 76 | + @RetryingTest(maxAttempts = 3) |
77 | 77 | void shouldThrowIfGoBinaryNotFoundChartYaml() { |
78 | 78 | var templateDependencies = Map.<String, String>of(); |
79 | 79 | assertThatThrownBy(() -> helmEvaluator.evaluateTemplate("/foo/bar/baz.yaml", "", templateDependencies)) |
80 | 80 | .isInstanceOf(IllegalStateException.class) |
81 | 81 | .hasMessage("Evaluation error in Go library: source file Chart.yaml not found"); |
82 | 82 |
|
83 | | - assertThat(logTester.logs(Level.DEBUG)) |
84 | | - .contains( |
85 | | - "[sonar-helm-for-iac] Exception encountered, printing recorded logs", |
86 | | - "[sonar-helm-for-iac] Reading 0 bytes of file /foo/bar/baz.yaml from stdin", |
87 | | - "[sonar-helm-for-iac] Read in total 1 files from stdin; evaluating template </foo/bar/baz.yaml>", |
88 | | - "[sonar-helm-for-iac] End of recorded logs"); |
| 83 | + var logs = logTester.logs(Level.DEBUG).stream().filter(log -> !log.startsWith("Preparing Helm analysis for platform")).toList(); |
| 84 | + assertThat(logs) |
| 85 | + .contains("[sonar-helm-for-iac] Exception encountered, printing recorded logs"); |
89 | 86 | } |
90 | 87 |
|
91 | 88 | @Test |
|
0 commit comments