Browse code

move TestMount to integration

Victor Vieux authored on 2013/11/15 08:17:31
Showing 2 changed files
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"io"
10 10
 	"io/ioutil"
11 11
 	"os"
12
-	"path"
13 12
 	"testing"
14 13
 	"time"
15 14
 )
... ...
@@ -121,41 +120,6 @@ func TestRegister(t *testing.T) {
121 121
 	}
122 122
 }
123 123
 
124
-func TestMount(t *testing.T) {
125
-	graph := tempGraph(t)
126
-	defer os.RemoveAll(graph.Root)
127
-	archive, err := fakeTar()
128
-	if err != nil {
129
-		t.Fatal(err)
130
-	}
131
-	image, err := graph.Create(archive, nil, "Testing", "", nil)
132
-	if err != nil {
133
-		t.Fatal(err)
134
-	}
135
-	tmp, err := ioutil.TempDir("", "docker-test-graph-mount-")
136
-	if err != nil {
137
-		t.Fatal(err)
138
-	}
139
-	defer os.RemoveAll(tmp)
140
-	rootfs := path.Join(tmp, "rootfs")
141
-	if err := os.MkdirAll(rootfs, 0700); err != nil {
142
-		t.Fatal(err)
143
-	}
144
-	rw := path.Join(tmp, "rw")
145
-	if err := os.MkdirAll(rw, 0700); err != nil {
146
-		t.Fatal(err)
147
-	}
148
-	if err := image.Mount(rootfs, rw); err != nil {
149
-		t.Fatal(err)
150
-	}
151
-	// FIXME: test for mount contents
152
-	defer func() {
153
-		if err := Unmount(rootfs); err != nil {
154
-			t.Error(err)
155
-		}
156
-	}()
157
-}
158
-
159 124
 // Test that an image can be deleted by its shorthand prefix
160 125
 func TestDeletePrefix(t *testing.T) {
161 126
 	graph := tempGraph(t)
162 127
new file mode 100644
... ...
@@ -0,0 +1,57 @@
0
+package docker
1
+
2
+import (
3
+	"github.com/dotcloud/docker"
4
+	"io/ioutil"
5
+	"os"
6
+	"path"
7
+	"testing"
8
+)
9
+
10
+func TestMount(t *testing.T) {
11
+	graph := tempGraph(t)
12
+	defer os.RemoveAll(graph.Root)
13
+	archive, err := fakeTar()
14
+	if err != nil {
15
+		t.Fatal(err)
16
+	}
17
+	image, err := graph.Create(archive, nil, "Testing", "", nil)
18
+	if err != nil {
19
+		t.Fatal(err)
20
+	}
21
+	tmp, err := ioutil.TempDir("", "docker-test-graph-mount-")
22
+	if err != nil {
23
+		t.Fatal(err)
24
+	}
25
+	defer os.RemoveAll(tmp)
26
+	rootfs := path.Join(tmp, "rootfs")
27
+	if err := os.MkdirAll(rootfs, 0700); err != nil {
28
+		t.Fatal(err)
29
+	}
30
+	rw := path.Join(tmp, "rw")
31
+	if err := os.MkdirAll(rw, 0700); err != nil {
32
+		t.Fatal(err)
33
+	}
34
+	if err := image.Mount(rootfs, rw); err != nil {
35
+		t.Fatal(err)
36
+	}
37
+	// FIXME: test for mount contents
38
+	defer func() {
39
+		if err := docker.Unmount(rootfs); err != nil {
40
+			t.Error(err)
41
+		}
42
+	}()
43
+}
44
+
45
+//FIXME: duplicate
46
+func tempGraph(t *testing.T) *docker.Graph {
47
+	tmp, err := ioutil.TempDir("", "docker-graph-")
48
+	if err != nil {
49
+		t.Fatal(err)
50
+	}
51
+	graph, err := docker.NewGraph(tmp)
52
+	if err != nil {
53
+		t.Fatal(err)
54
+	}
55
+	return graph
56
+}