aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/sonarsource/scanner/cli/MainTest.java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2022-03-21 11:56:18 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2022-03-22 09:01:38 +0100
commit8c73aabed5dee00d5e184750984099b63aaf676a (patch)
tree01342122ea09c7eabb43eef00fe0cb8b80335ba6 /src/test/java/org/sonarsource/scanner/cli/MainTest.java
parent62768e25da3981a8ffd3778accfcd459d79ede24 (diff)
downloadsonar-scanner-cli-8c73aabed5dee00d5e184750984099b63aaf676a.tar.gz
sonar-scanner-cli-8c73aabed5dee00d5e184750984099b63aaf676a.zip
SQSCANNER-101 Do not parse configuration twice
Diffstat (limited to 'src/test/java/org/sonarsource/scanner/cli/MainTest.java')
-rw-r--r--src/test/java/org/sonarsource/scanner/cli/MainTest.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
index 4c3b54c..80847be 100644
--- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java
+++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java
@@ -253,8 +253,8 @@ public class MainTest {
@Test
public void should_log_SonarCloud_server() {
Properties p = new Properties();
+ p.setProperty("sonar.host.url", "https://sonarcloud.io");
when(conf.properties()).thenReturn(p);
- when(conf.isSonarCloud(null)).thenReturn(true);
when(cli.getInvokedFrom()).thenReturn("");
Main main = new Main(exit, cli, conf, scannerFactory, logs);
@@ -262,6 +262,31 @@ public class MainTest {
verify(logs).info("Analyzing on SonarCloud");
}
+ // SQSCANNER-57
+ @Test
+ public void should_return_true_is_sonar_cloud() {
+
+ Properties properties = new Properties();
+ properties.setProperty("sonar.host.url", "https://sonarcloud.io");
+
+ assertThat(Main.isSonarCloud(properties)).isTrue();
+ }
+
+ // SQSCANNER-57
+ @Test
+ public void should_return_false_is_sonar_cloud() {
+ Properties properties = new Properties();
+ properties.setProperty("sonar.host.url", "https://mysonarqube.com:9000/");
+
+ assertThat(Main.isSonarCloud(properties)).isFalse();
+ }
+
+ // SQSCANNER-57
+ @Test
+ public void should_return_false_is_sonar_cloud_host_is_null() {
+ assertThat(Main.isSonarCloud(new Properties())).isFalse();
+ }
+
@Test
public void should_configure_logging() {
Properties analysisProps = testLogging("sonar.verbose", "true");