mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move TestCopyVolumeContent to integration-cli
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
parent
9a7c5be7d1
commit
e88487b321
2 changed files with 24 additions and 34 deletions
|
@ -1390,3 +1390,27 @@ func TestCopyVolumeUidGid(t *testing.T) {
|
||||||
|
|
||||||
logDone("run - copy uid/gid for volume")
|
logDone("run - copy uid/gid for volume")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test for #1582
|
||||||
|
func TestCopyVolumeContent(t *testing.T) {
|
||||||
|
name := "testruncopyvolumecontent"
|
||||||
|
defer deleteImages(name)
|
||||||
|
defer deleteAllContainers()
|
||||||
|
_, err := buildImage(name,
|
||||||
|
`FROM busybox
|
||||||
|
RUN mkdir -p /hello/local && echo hello > /hello/local/world`,
|
||||||
|
true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that the content is copied from the image to the volume
|
||||||
|
cmd := exec.Command(dockerBinary, "run", "--rm", "-v", "/hello", name, "sh", "-c", "find", "/hello")
|
||||||
|
out, _, err := runCommandWithOutput(cmd)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err, out)
|
||||||
|
}
|
||||||
|
if !(strings.Contains(out, "/hello/local/world") && strings.Contains(out, "/hello/local")) {
|
||||||
|
t.Fatal("Container failed to transfer content to volume")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -370,40 +370,6 @@ func tempDir(t *testing.T) string {
|
||||||
return tmpDir
|
return tmpDir
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for #1582
|
|
||||||
func TestCopyVolumeContent(t *testing.T) {
|
|
||||||
eng := NewTestEngine(t)
|
|
||||||
r := mkDaemonFromEngine(eng, t)
|
|
||||||
defer r.Nuke()
|
|
||||||
|
|
||||||
// Put some content in a directory of a container and commit it
|
|
||||||
container1, _, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello/local && echo hello > /hello/local/world"}, t)
|
|
||||||
defer r.Destroy(container1)
|
|
||||||
|
|
||||||
if container1.State.IsRunning() {
|
|
||||||
t.Errorf("Container shouldn't be running")
|
|
||||||
}
|
|
||||||
if err := container1.Run(); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if container1.State.IsRunning() {
|
|
||||||
t.Errorf("Container shouldn't be running")
|
|
||||||
}
|
|
||||||
|
|
||||||
img, err := r.Commit(container1, "", "", "unit test commited image", "", true, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test that the content is copied from the image to the volume
|
|
||||||
tmpDir1 := tempDir(t)
|
|
||||||
defer os.RemoveAll(tmpDir1)
|
|
||||||
stdout1, _ := runContainer(eng, r, []string{"-v", "/hello", img.ID, "find", "/hello"}, t)
|
|
||||||
if !(strings.Contains(stdout1, "/hello/local/world") && strings.Contains(stdout1, "/hello/local")) {
|
|
||||||
t.Fatal("Container failed to transfer content to volume")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBindMounts(t *testing.T) {
|
func TestBindMounts(t *testing.T) {
|
||||||
eng := NewTestEngine(t)
|
eng := NewTestEngine(t)
|
||||||
r := mkDaemonFromEngine(eng, t)
|
r := mkDaemonFromEngine(eng, t)
|
||||||
|
|
Loading…
Reference in a new issue