|
@@ -9,6 +9,8 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"testing"
|
|
"testing"
|
|
"time"
|
|
"time"
|
|
|
|
+
|
|
|
|
+ "github.com/dotcloud/docker/archive"
|
|
)
|
|
)
|
|
|
|
|
|
func TestBuildCacheADD(t *testing.T) {
|
|
func TestBuildCacheADD(t *testing.T) {
|
|
@@ -1130,6 +1132,50 @@ func TestBuildADDLocalAndRemoteFilesWithCache(t *testing.T) {
|
|
logDone("build - add local and remote file with cache")
|
|
logDone("build - add local and remote file with cache")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func testContextTar(t *testing.T, compression archive.Compression) {
|
|
|
|
+ contextDirectory := filepath.Join(workingDirectory, "build_tests", "TestContextTar")
|
|
|
|
+ context, err := archive.Tar(contextDirectory, compression)
|
|
|
|
+
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatalf("failed to build context tar: %v", err)
|
|
|
|
+ }
|
|
|
|
+ buildCmd := exec.Command(dockerBinary, "build", "-t", "contexttar", "-")
|
|
|
|
+ buildCmd.Stdin = context
|
|
|
|
+
|
|
|
|
+ out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
+ if err != nil || exitCode != 0 {
|
|
|
|
+ t.Fatalf("build failed to complete: %v %v", out, err)
|
|
|
|
+ }
|
|
|
|
+ deleteImages("contexttar")
|
|
|
|
+ logDone(fmt.Sprintf("build - build an image with a context tar, compression: %v", compression))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestContextTarGzip(t *testing.T) {
|
|
|
|
+ testContextTar(t, archive.Gzip)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestContextTarNoCompression(t *testing.T) {
|
|
|
|
+ testContextTar(t, archive.Uncompressed)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestNoContext(t *testing.T) {
|
|
|
|
+ buildCmd := exec.Command(dockerBinary, "build", "-t", "nocontext", "-")
|
|
|
|
+ buildCmd.Stdin = strings.NewReader("FROM busybox\nCMD echo ok\n")
|
|
|
|
+
|
|
|
|
+ out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
+ if err != nil || exitCode != 0 {
|
|
|
|
+ t.Fatalf("build failed to complete: %v %v", out, err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ out, exitCode, err = cmd(t, "run", "nocontext")
|
|
|
|
+ if out != "ok\n" {
|
|
|
|
+ t.Fatalf("run produced invalid output: %q, expected %q", out, "ok")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deleteImages("nocontext")
|
|
|
|
+ logDone("build - build an image with no context")
|
|
|
|
+}
|
|
|
|
+
|
|
// TODO: TestCaching
|
|
// TODO: TestCaching
|
|
func TestBuildADDLocalAndRemoteFilesWithoutCache(t *testing.T) {
|
|
func TestBuildADDLocalAndRemoteFilesWithoutCache(t *testing.T) {
|
|
name := "testbuildaddlocalandremotefilewithoutcache"
|
|
name := "testbuildaddlocalandremotefilewithoutcache"
|