Search in sources :

Example 91 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootBuildImageIntegrationTests method buildsImageWithVolumeCaches.

@TestTemplate
void buildsImageWithVolumeCaches() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    String projectName = this.gradleBuild.getProjectDir().getName();
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
    assertThat(result.getOutput()).contains("---> Test Info buildpack building");
    assertThat(result.getOutput()).contains("---> Test Info buildpack done");
    removeImages(projectName);
    deleteVolumes("cache-" + projectName + ".build", "cache-" + projectName + ".launch");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 92 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootBuildImageIntegrationTests method buildsImageWithCommandLineOptions.

@TestTemplate
void buildsImageWithCommandLineOptions() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT", "--imageName=example/test-image-cmd", "--builder=projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1", "--runImage=projects.registry.vmware.com/springboot/run:tiny-cnb");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("example/test-image-cmd");
    assertThat(result.getOutput()).contains("---> Test Info buildpack building");
    assertThat(result.getOutput()).contains("---> Test Info buildpack done");
    removeImages("example/test-image-cmd");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 93 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootBuildImageIntegrationTests method failsWithBuilderError.

@TestTemplate
void failsWithBuilderError() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
    assertThat(result.getOutput()).contains("Forced builder failure");
    assertThat(result.getOutput()).containsPattern("Builder lifecycle '.*' failed with status code");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 94 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootBuildImageIntegrationTests method buildsImageWithCustomBuilderAndRunImage.

@TestTemplate
void buildsImageWithCustomBuilderAndRunImage() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("example/test-image-custom");
    assertThat(result.getOutput()).contains("---> Test Info buildpack building");
    assertThat(result.getOutput()).contains("---> Test Info buildpack done");
    removeImages("example/test-image-custom");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 95 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootBuildImageIntegrationTests method buildsImageWithBuildpackFromBuilder.

@TestTemplate
void buildsImageWithBuildpackFromBuilder() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    String projectName = this.gradleBuild.getProjectDir().getName();
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
    assertThat(result.getOutput()).contains("---> Test Info buildpack building").contains("---> Test Info buildpack done");
    removeImages(projectName);
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

BuildResult (org.gradle.testkit.runner.BuildResult)143 File (java.io.File)62 TestTemplate (org.junit.jupiter.api.TestTemplate)60 Test (org.junit.Test)47 Test (org.junit.jupiter.api.Test)20 StringWriter (java.io.StringWriter)19 GradleRunner (org.gradle.testkit.runner.GradleRunner)17 Test (org.testng.annotations.Test)10 ImageReference (org.springframework.boot.buildpack.platform.docker.type.ImageReference)8 JarFile (java.util.jar.JarFile)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 TestHelpers.findFile (me.tatarka.TestHelpers.findFile)6 TestHelpers.writeFile (me.tatarka.TestHelpers.writeFile)6 ContainerConfig (com.github.dockerjava.api.model.ContainerConfig)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 PrintWriter (java.io.PrintWriter)5 Path (java.nio.file.Path)5 BufferedReader (java.io.BufferedReader)4