Polish "Add pullPolicy option for image building"
See gh-22736
This commit is contained in:
@@ -126,6 +126,31 @@ class BootBuildImageIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void buildsImageWithPullPolicy() throws IOException {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(projectName));
|
||||
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=ALWAYS");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("Pulled builder image").contains("Pulled run image");
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
|
||||
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
|
||||
}
|
||||
|
||||
result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("Pulled builder image").doesNotContain("Pulled run image");
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
|
||||
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
|
||||
}
|
||||
finally {
|
||||
new DockerApi().image().remove(imageReference, false);
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWithLaunchScript() {
|
||||
writeMainClass();
|
||||
|
||||
@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Scott Frederick
|
||||
* @author Andrey Shlykov
|
||||
*/
|
||||
class BootBuildImageTests {
|
||||
|
||||
@@ -196,12 +197,12 @@ class BootBuildImageTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingDefaultConfigurationThenRequestHasNoPullDisabled() {
|
||||
void whenUsingDefaultConfigurationThenRequestHasAlwaysPullPolicy() {
|
||||
assertThat(this.buildImage.createRequest().getPullPolicy()).isEqualTo(PullPolicy.ALWAYS);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenNoPullIsEnabledThenRequestHasNoPullEnabled() {
|
||||
void whenPullPolicyIsConfiguredThenRequestHasPullPolicy() {
|
||||
this.buildImage.setPullPolicy(PullPolicy.NEVER);
|
||||
assertThat(this.buildImage.createRequest().getPullPolicy()).isEqualTo(PullPolicy.NEVER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user