diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2022-03-21 11:56:18 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2022-03-22 09:01:38 +0100 |
commit | 8c73aabed5dee00d5e184750984099b63aaf676a (patch) | |
tree | 01342122ea09c7eabb43eef00fe0cb8b80335ba6 /src/test | |
parent | 62768e25da3981a8ffd3778accfcd459d79ede24 (diff) | |
download | sonar-scanner-cli-8c73aabed5dee00d5e184750984099b63aaf676a.tar.gz sonar-scanner-cli-8c73aabed5dee00d5e184750984099b63aaf676a.zip |
SQSCANNER-101 Do not parse configuration twice
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/ConfTest.java | 34 | ||||
-rw-r--r-- | src/test/java/org/sonarsource/scanner/cli/MainTest.java | 27 |
2 files changed, 26 insertions, 35 deletions
diff --git a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java index ec51b8f..57e4cb2 100644 --- a/src/test/java/org/sonarsource/scanner/cli/ConfTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/ConfTest.java @@ -337,38 +337,4 @@ public class ConfTest { assertThat(properties.get("sonar.prop")).isEqualTo("expected"); } - // SQSCANNER-57 - @Test - public void should_return_true_is_sonar_cloud() { - - args.setProperty("sonar.host.url", "https://sonarcloud.io"); - - conf.properties(); - - assertThat(conf.isSonarCloud(null)).isTrue(); - } - - // SQSCANNER-57 - @Test - public void should_return_false_is_sonar_cloud() { - args.setProperty("sonar.host.url", "https://mysonarqube.com:9000/"); - - //Still returns false, sonarcloud not detected in the content of the url - Properties properties = conf.properties(); - - assertThat(properties.getProperty("sonar.host.url")).isEqualTo("https://mysonarqube.com:9000/"); - - assertThat(conf.isSonarCloud(null)).isFalse(); - } - - // SQSCANNER-57 - @Test - public void should_return_false_is_sonar_cloud_host_is_null() { - - Properties emptyProperties = new Properties(); - - assertThat(emptyProperties.getProperty("sonar.host.url")).isNull(); - - assertThat(conf.isSonarCloud(emptyProperties)).isFalse(); - } } 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"); |