2014-02-25 11:17:48 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuildSixtySteps(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildSixtySteps")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "foobuildsixtysteps", ".")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
2014-04-03 20:22:32 -04:00
|
|
|
deleteImages("foobuildsixtysteps")
|
2014-02-25 11:17:48 -05:00
|
|
|
|
|
|
|
logDone("build - build an image with sixty build steps")
|
|
|
|
}
|
|
|
|
|
2014-04-09 10:21:22 -04:00
|
|
|
func TestAddSingleFileToRoot(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToRoot")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add single file to root")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddSingleFileToExistDir(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToExistDir")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add single file to existing dir")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddSingleFileToNonExistDir(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToNonExistDir")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add single file to non-existing dir")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddDirContentToRoot(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "DirContentToRoot")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add directory contents to root")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddDirContentToExistDir(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "DirContentToExistDir")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add directory contents to existing dir")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddWholeDirToRoot(t *testing.T) {
|
|
|
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
|
|
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "WholeDirToRoot")
|
|
|
|
buildCmd.Dir = buildDirectory
|
|
|
|
out, exitCode, err := runCommandWithOutput(buildCmd)
|
|
|
|
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
|
|
|
|
|
|
if err != nil || exitCode != 0 {
|
|
|
|
t.Fatal("failed to build the image")
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteImages("testaddimg")
|
|
|
|
|
|
|
|
logDone("build - add whole directory to root")
|
|
|
|
}
|
|
|
|
|
2014-02-25 11:17:48 -05:00
|
|
|
// TODO: TestCaching
|
|
|
|
|
|
|
|
// TODO: TestADDCacheInvalidation
|