aboutsummaryrefslogtreecommitdiffstats
path: root/it/src/test/java/com/sonarsource
diff options
context:
space:
mode:
authorJacek <52388493+jacek-poreda-sonarsource@users.noreply.github.com>2019-10-01 08:09:09 +0200
committerGitHub <noreply@github.com>2019-10-01 08:09:09 +0200
commitb1884daf731fde33075b4fecce6ff85be40e13b2 (patch)
tree3ffdb8ceed51bd219b97e78da309981c878c42fc /it/src/test/java/com/sonarsource
parent70da1689e80a7afd3f107e9ae9d3deac94f6c9b9 (diff)
downloadsonar-scanner-cli-b1884daf731fde33075b4fecce6ff85be40e13b2.tar.gz
sonar-scanner-cli-b1884daf731fde33075b4fecce6ff85be40e13b2.zip
SQSCANNER-63 Make SONAR_HOST_URL environment variable available (#74)4.2.0.1873
Diffstat (limited to 'it/src/test/java/com/sonarsource')
-rw-r--r--it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java
index f748d21..d444a98 100644
--- a/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java
+++ b/it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java
@@ -20,6 +20,7 @@
package com.sonarsource.scanner.it;
import com.sonar.orchestrator.build.BuildResult;
+import com.sonar.orchestrator.build.BuildRunner;
import com.sonar.orchestrator.build.SonarScanner;
import java.io.File;
import java.io.IOException;
@@ -140,7 +141,7 @@ public class ScannerTest extends ScannerTestCase {
}
@Test
- public void should_use_environment_props() {
+ public void should_use_json_environment_props() {
SonarScanner build = newScanner(new File("projects/simple-sample-no-properties"))
.setEnvironmentVariable("SONARQUBE_SCANNER_PARAMS", "{"
+ "\"sonar.projectKey\" : \"sample\"," +
@@ -152,6 +153,18 @@ public class ScannerTest extends ScannerTestCase {
}
@Test
+ public void should_use_environment_prop() {
+ SonarScanner build = newScanner(new File("projects/simple-sample"))
+ .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org");
+
+ BuildRunner runner = new BuildRunner(orchestrator.getConfiguration());
+ BuildResult buildResult = runner.runQuietly(null, build);
+
+ assertThat(buildResult.isSuccess()).isFalse();
+ assertThat(buildResult.getLogs()).contains("SonarQube server [http://from-env.org] can not be reached");
+ }
+
+ @Test
public void should_skip_analysis() {
SonarScanner build = newScanner(new File("projects/simple-sample"))
.setProperty("sonar.host.url", "http://foo")
@@ -164,11 +177,13 @@ public class ScannerTest extends ScannerTestCase {
@Test
public void should_fail_if_unable_to_connect() {
SonarScanner build = newScanner(new File("projects/simple-sample"))
+ //env property should be overridden
+ .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org")
.setProperty("sonar.host.url", "http://foo");
BuildResult result = orchestrator.executeBuildQuietly(build);
// expect build failure
- assertThat(result.getStatus()).isNotEqualTo(0);
+ assertThat(result.isSuccess()).isFalse();
// with the following message
assertThat(result.getLogs()).contains("SonarQube server [http://foo] can not be reached");
}