From 8c73aabed5dee00d5e184750984099b63aaf676a Mon Sep 17 00:00:00 2001
From: Julien HENRY <julien.henry@sonarsource.com>
Date: Mon, 21 Mar 2022 11:56:18 +0100
Subject: SQSCANNER-101 Do not parse configuration twice

---
 .../java/org/sonarsource/scanner/cli/MainTest.java | 27 +++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

(limited to 'src/test/java/org/sonarsource/scanner/cli/MainTest.java')

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");
-- 
cgit v1.2.3