Move volume build test to integration-cli

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
LK4D4 2014-05-22 23:16:27 +04:00 committed by Alexandr Morozov
parent e5ba9f6443
commit 11f7f0bf9b
2 changed files with 33 additions and 20 deletions

View File

@ -10,6 +10,25 @@ import (
"time"
)
func checkSimpleBuild(t *testing.T, dockerfile, name, inspectFormat, expected string) {
buildCmd := exec.Command(dockerBinary, "build", "-t", name, "-")
buildCmd.Stdin = strings.NewReader(dockerfile)
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")
}
inspectCmd := exec.Command(dockerBinary, "inspect", "-f", inspectFormat, name)
out, exitCode, err = runCommandWithOutput(inspectCmd)
if err != nil || exitCode != 0 {
t.Fatalf("failed to inspect the image: %s", out)
}
out = strings.TrimSpace(out)
if out != expected {
t.Fatalf("From format %s expected %s, got %s", inspectFormat, expected, out)
}
}
func TestBuildCacheADD(t *testing.T) {
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "1")
buildCmd := exec.Command(dockerBinary, "build", "-t", "testcacheadd1", ".")
@ -413,6 +432,20 @@ func TestBuildRm(t *testing.T) {
logDone("build - ensure --rm=false overrides the default")
}
func TestBuildWithVolume(t *testing.T) {
checkSimpleBuild(t,
`
FROM scratch
VOLUME /test
`,
"testbuildimg",
"{{json .config.Volumes}}",
`{"/test":{}}`)
deleteImages("testbuildimg")
logDone("build - with volume")
}
// TODO: TestCaching
// TODO: TestADDCacheInvalidation

View File

@ -414,26 +414,6 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u
return image, err
}
func TestVolume(t *testing.T) {
img, err := buildImage(testContextTemplate{`
from {IMAGE}
volume /test
cmd Hello world
`, nil, nil}, t, nil, true)
if err != nil {
t.Fatal(err)
}
if len(img.Config.Volumes) == 0 {
t.Fail()
}
for key := range img.Config.Volumes {
if key != "/test" {
t.Fail()
}
}
}
func TestBuildMaintainer(t *testing.T) {
img, err := buildImage(testContextTemplate{`
from {IMAGE}