Need to pull image first to ensure that it exists
@@ -4,17 +4,19 @@ import com.bmuschko.gradle.docker.AbstractGroovyDslFunctionalTest
class DockerSaveImageFunctionalTest extends AbstractGroovyDslFunctionalTest {
- private static final String IMAGE = "alpine:3.4"
+ private static final String IMAGE = 'alpine:3.4'
private static final String BUILD_DIR = 'build/docker'
private static final String CONTROL_SAVED_IMAGE = "$BUILD_DIR/alpine-3.4-docker-image-control.tar"
private static final String IMAGE_FILE = "$BUILD_DIR/alpine-3.4-docker-image.tar"
private static final String COMPRESSED_IMAGE_FILE = "$BUILD_DIR/alpine-3.4-compressed-docker-image.tar.gz"
def "can save Docker image without compression"() {
+ buildFile << pullImageTask()
buildFile << """
import com.bmuschko.gradle.docker.tasks.image.DockerSaveImage
task saveImage(type: DockerSaveImage) {
+ dependsOn pullImage
image = "${IMAGE}"
destFile = file("${IMAGE_FILE}")
}
@@ -28,10 +30,12 @@ class DockerSaveImageFunctionalTest extends AbstractGroovyDslFunctionalTest {
}
def "can save Docker image with compression"() {
+ buildFile << pullImageTask()
buildFile << """
import com.bmuschko.gradle.docker.tasks.image.DockerSaveImage
task saveImageControl(type: DockerSaveImage) {
+ dependsOn pullImage
image = "${IMAGE}"
destFile = file("${CONTROL_SAVED_IMAGE}")
}
@@ -49,4 +53,14 @@ class DockerSaveImageFunctionalTest extends AbstractGroovyDslFunctionalTest {
then:
file(CONTROL_SAVED_IMAGE).size() > file(COMPRESSED_IMAGE_FILE).size()
}
+
+ static String pullImageTask() {
+ """
+ import com.bmuschko.gradle.docker.tasks.image.DockerPullImage
+
+ task pullImage(type: DockerPullImage) {
+ image = "${IMAGE}"
+ }
+ """
+ }
}
