mirror of https://github.com/docker/docs.git
move TestMount to integration
This commit is contained in:
parent
661a8a0e0c
commit
596810d8db
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -121,41 +120,6 @@ func TestRegister(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMount(t *testing.T) {
|
|
||||||
graph := tempGraph(t)
|
|
||||||
defer os.RemoveAll(graph.Root)
|
|
||||||
archive, err := fakeTar()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
image, err := graph.Create(archive, nil, "Testing", "", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
tmp, err := ioutil.TempDir("", "docker-test-graph-mount-")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
rootfs := path.Join(tmp, "rootfs")
|
|
||||||
if err := os.MkdirAll(rootfs, 0700); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
rw := path.Join(tmp, "rw")
|
|
||||||
if err := os.MkdirAll(rw, 0700); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := image.Mount(rootfs, rw); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// FIXME: test for mount contents
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(rootfs); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test that an image can be deleted by its shorthand prefix
|
// Test that an image can be deleted by its shorthand prefix
|
||||||
func TestDeletePrefix(t *testing.T) {
|
func TestDeletePrefix(t *testing.T) {
|
||||||
graph := tempGraph(t)
|
graph := tempGraph(t)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/dotcloud/docker"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMount(t *testing.T) {
|
||||||
|
graph := tempGraph(t)
|
||||||
|
defer os.RemoveAll(graph.Root)
|
||||||
|
archive, err := fakeTar()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
image, err := graph.Create(archive, nil, "Testing", "", nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
tmp, err := ioutil.TempDir("", "docker-test-graph-mount-")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmp)
|
||||||
|
rootfs := path.Join(tmp, "rootfs")
|
||||||
|
if err := os.MkdirAll(rootfs, 0700); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
rw := path.Join(tmp, "rw")
|
||||||
|
if err := os.MkdirAll(rw, 0700); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := image.Mount(rootfs, rw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// FIXME: test for mount contents
|
||||||
|
defer func() {
|
||||||
|
if err := docker.Unmount(rootfs); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: duplicate
|
||||||
|
func tempGraph(t *testing.T) *docker.Graph {
|
||||||
|
tmp, err := ioutil.TempDir("", "docker-graph-")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
graph, err := docker.NewGraph(tmp)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return graph
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue