Skip to content

Commit

Permalink
Add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
dorian-burihabwa-sonarsource committed Nov 4, 2024
1 parent a4347b8 commit 2ecd9a1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/groovy/org/sonarqube/gradle/FunctionalTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.sonarqube.gradle


import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.UnexpectedBuildFailure
import spock.lang.Specification
import spock.lang.TempDir

Expand Down Expand Up @@ -548,4 +549,28 @@ class FunctionalTests extends Specification {
testSources[0].endsWith("""$projectDir/integrationTests/run-all.sh""")
testSources[1].endsWith("""$projectDir/test-license.sh""")
}

def "task fails with an IllegalStateException when failing to reach the server"() {
given:
settingsFile << "rootProject.name = 'java-task-toolchains'"
buildFile << """
plugins {
id 'org.sonarqube'
}
"""

when:
GradleRunner.create()
.withProjectDir(projectDir.toFile())
.forwardOutput()
.withArguments('sonar', '-Dsonar.host.url=http://localhost:0')
.withPluginClasspath()
.build()

then:
def exception = thrown(RuntimeException.class)
assert exception instanceof UnexpectedBuildFailure
// The cause of the issue is not reported here but we can find it in the error message
assert exception.message.contains("java.lang.IllegalStateException: Failed to get server version")
}
}

0 comments on commit 2ecd9a1

Please sign in to comment.