mirror of https://github.com/docker/docs.git
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:
parent
e5ba9f6443
commit
11f7f0bf9b
|
@ -10,6 +10,25 @@ import (
|
||||||
"time"
|
"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) {
|
func TestBuildCacheADD(t *testing.T) {
|
||||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "1")
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "1")
|
||||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "testcacheadd1", ".")
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testcacheadd1", ".")
|
||||||
|
@ -413,6 +432,20 @@ func TestBuildRm(t *testing.T) {
|
||||||
logDone("build - ensure --rm=false overrides the default")
|
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: TestCaching
|
||||||
|
|
||||||
// TODO: TestADDCacheInvalidation
|
// TODO: TestADDCacheInvalidation
|
||||||
|
|
|
@ -414,26 +414,6 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u
|
||||||
return image, err
|
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) {
|
func TestBuildMaintainer(t *testing.T) {
|
||||||
img, err := buildImage(testContextTemplate{`
|
img, err := buildImage(testContextTemplate{`
|
||||||
from {IMAGE}
|
from {IMAGE}
|
||||||
|
|
Loading…
Reference in New Issue