Skip to content

Commit

Permalink
Merge pull request #431 from nebula-plugins/move-to-testkit
Browse files Browse the repository at this point in the history
Move to testkit
  • Loading branch information
rpalcolea authored Nov 20, 2023
2 parents 8493de1 + e5ebd15 commit d8ca7c4
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 162 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.netflix.gradle.plugins

import nebula.test.IntegrationTestKitSpec

abstract class BaseIntegrationTestKitSpec extends IntegrationTestKitSpec {
def setup() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@

package com.netflix.gradle.plugins.application

import nebula.test.IntegrationSpec
import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec

class OspackageApplicationDaemonPluginLauncherSpec extends IntegrationSpec {
class OspackageApplicationDaemonPluginLauncherSpec extends BaseIntegrationTestKitSpec {

def 'daemon script from application'() {
writeHelloWorld('nebula.test')
buildFile << """
${applyPlugin(OspackageApplicationDaemonPlugin)}
plugins {
id 'com.netflix.nebula.ospackage-application-daemon'
}
application {
mainClass = 'nebula.test.HelloWorld'
}
""".stripIndent()

when:
runTasksSuccessfully('buildDeb')
runTasks('buildDeb')

then:
def archivePath = file("build/distributions/${moduleName}_0_all.deb")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@

package com.netflix.gradle.plugins.application

import nebula.test.IntegrationSpec
import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec

class OspackageApplicationPluginLauncherSpec extends IntegrationSpec {
class OspackageApplicationPluginLauncherSpec extends BaseIntegrationTestKitSpec {
def 'application shows up in deb'() {
writeHelloWorld('nebula.test')
buildFile << """
${applyPlugin(OspackageApplicationPlugin)}
plugins {
id 'com.netflix.nebula.ospackage-application'
}
application {
mainClass = 'nebula.test.HelloWorld'
}
""".stripIndent()

when:
runTasksSuccessfully('buildDeb')
runTasks('buildDeb')

then:
def archivePath = file("build/distributions/${moduleName}_0_all.deb")
Expand All @@ -47,7 +49,9 @@ class OspackageApplicationPluginLauncherSpec extends IntegrationSpec {
def 'can customize destination'() {
writeHelloWorld('nebula.test')
buildFile << """
${applyPlugin(OspackageApplicationPlugin)}
plugins {
id 'com.netflix.nebula.ospackage-application'
}
ospackage_application {
prefix = '/usr/local'
}
Expand All @@ -58,7 +62,7 @@ class OspackageApplicationPluginLauncherSpec extends IntegrationSpec {
""".stripIndent()

when:
runTasksSuccessfully('buildDeb')
runTasks('buildDeb')

then:
def archivePath = file("build/distributions/${moduleName}_0_all.deb")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,42 @@

package com.netflix.gradle.plugins.application

import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec
import com.netflix.gradle.plugins.deb.Scanner
import nebula.test.IntegrationSpec
import org.junit.Rule
import org.junit.contrib.java.lang.system.ProvideSystemProperty
import spock.lang.Shared
import spock.lang.Unroll
import spock.lang.IgnoreIf

import java.util.jar.JarFile

class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
class OspackageApplicationSpringBootPluginLauncherSpec extends BaseIntegrationTestKitSpec {
@Rule
public final ProvideSystemProperty ignoreDeprecations = new ProvideSystemProperty("ignoreDeprecations", "true")

def 'plugin throws exception if spring-boot plugin not applied'() {
buildFile << """
${applyPlugin(OspackageApplicationSpringBootPlugin)}
plugins {
id 'com.netflix.nebula.ospackage-application-spring-boot'
}
"""

when:
def result = runTasks("help")
def result = runTasksAndFail("help")

then:
result.failure.getCause().getCause().getCause().message == "The 'org.springframework.boot' plugin must be applied before applying this plugin"
result.output.contains("The 'org.springframework.boot' plugin must be applied before applying this plugin")
}

String buildScript(String bootVersion, File startScript) {
writeHelloWorld('nebula.test')

return """
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:$bootVersion'
}
plugins {
id 'org.springframework.boot' version '$bootVersion'
id 'com.netflix.nebula.ospackage-application-spring-boot'
}
apply plugin: 'org.springframework.boot'
${applyPlugin(OspackageApplicationSpringBootPlugin)}
mainClassName = 'nebula.test.HelloWorld'
repositories {
Expand Down Expand Up @@ -91,7 +84,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
buildFile << buildScript(bootVersion, null)

when:
runTasksSuccessfully('build', 'buildDeb')
runTasks('build', 'buildDeb')

then:
final archivePath = file("build/distributions/test_0_all.deb")
Expand Down Expand Up @@ -135,7 +128,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
def result = runTasks('runStartScript')

then:
result.standardOutput.contains('Hello Integration Test')
result.output.contains('Hello Integration Test')

where:
bootVersion << ['2.7.0']
Expand All @@ -156,10 +149,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
"""

when:
def result = runTasksSuccessfully('runStartScript')
def result = runTasks('runStartScript')

then:
result.standardOutput.contains('Hello Integration Test')
result.output.contains('Hello Integration Test')

where:
bootVersion << ['2.7.0']
Expand All @@ -177,7 +170,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
""".stripIndent()

when:
runTasksSuccessfully('buildDeb')
runTasks('buildDeb')

then:
final appName = "myapp-boot"
Expand Down Expand Up @@ -211,10 +204,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
"""

when:
def result = runTasksWithFailure('installDist')
def result = runTasksAndFail('installDist')

then:
result.standardError.contains("mainClass should be configured in order to generate a valid start script. i.e. mainClass = 'com.netflix.app.MyApp'")
result.output.contains("mainClass should be configured in order to generate a valid start script. i.e. mainClass = 'com.netflix.app.MyApp'")

where:
bootVersion << ['2.7.0']
Expand All @@ -233,10 +226,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
"""
when:
def result = runTasksWithFailure('installDist')
def result = runTasksAndFail('installDist')
then:
result.standardError.contains("No value has been specified for property 'mainClassName'")
result.output.contains("No value has been specified for property 'mainClassName'")
where:
bootVersion << ['2.4.0']
Expand Down
Loading

0 comments on commit d8ca7c4

Please sign in to comment.