mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
91b7d8ebd3
Fixes #5110 Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
124 lines
3.8 KiB
Go
124 lines
3.8 KiB
Go
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")
|
|
}
|
|
|
|
deleteImages("foobuildsixtysteps")
|
|
|
|
logDone("build - build an image with sixty build steps")
|
|
}
|
|
|
|
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")
|
|
}
|
|
|
|
// TODO: TestCaching
|
|
|
|
// TODO: TestADDCacheInvalidation
|