Переглянути джерело

Move TestCopyVolumeContent to integration-cli

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
LK4D4 11 роки тому
батько
коміт
e88487b321
2 змінених файлів з 24 додано та 34 видалено
  1. 24 0
      integration-cli/docker_cli_run_test.go
  2. 0 34
      integration/container_test.go

+ 24 - 0
integration-cli/docker_cli_run_test.go

@@ -1390,3 +1390,27 @@ func TestCopyVolumeUidGid(t *testing.T) {
 
 	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")
+	}
+}

+ 0 - 34
integration/container_test.go

@@ -370,40 +370,6 @@ func tempDir(t *testing.T) string {
 	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) {
 	eng := NewTestEngine(t)
 	r := mkDaemonFromEngine(eng, t)