diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2019-03-13 15:49:24 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-03-19 20:21:27 +0100 |
commit | 368cfd19508e128b68741ce6810a04547638522a (patch) | |
tree | b1f51955d7683c7f6c6d1f59bb2cd7076ee8a15a /sonar-scanner-engine/src/test/java/org/sonar/scanner/report | |
parent | acf96ad21a8d2165149b6808c18a8d49a1801222 (diff) | |
download | sonarqube-368cfd19508e128b68741ce6810a04547638522a.tar.gz sonarqube-368cfd19508e128b68741ce6810a04547638522a.zip |
SONAR-11631 Add sonar.buildString to scanner report
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/report')
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java index cf46878a7dd..75043c9997d 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java @@ -243,6 +243,33 @@ public class MetadataPublisherTest { } @Test + @UseDataProvider("buildStrings") + public void write_buildString(@Nullable String buildString, String expected) throws Exception { + when(projectInfo.getBuildString()).thenReturn(Optional.ofNullable(buildString)); + when(properties.organizationKey()).thenReturn(Optional.of("SonarSource")); + + File outputDir = temp.newFolder(); + ScannerReportWriter writer = new ScannerReportWriter(outputDir); + + underTest.publish(writer); + + ScannerReportReader reader = new ScannerReportReader(outputDir); + ScannerReport.Metadata metadata = reader.readMetadata(); + assertThat(metadata.getBuildString()).isEqualTo(expected); + } + + @DataProvider + public static Object[][] buildStrings() { + String randomBuildString = randomAlphabetic(15); + return new Object[][] { + {null, ""}, + {"", ""}, + {"5.6.3", "5.6.3"}, + {randomBuildString, randomBuildString} + }; + } + + @Test public void write_long_lived_branch_info() throws Exception { String branchName = "long-lived"; when(branches.branchName()).thenReturn(branchName); |