moby--moby/integration/graph_test.go

60 lines
1.1 KiB
Go
Raw Normal View History

2013-11-14 23:17:31 +00:00
package docker
import (
"github.com/dotcloud/docker"
2013-11-19 23:24:14 +00:00
"github.com/dotcloud/docker/graphdriver"
2013-11-14 23:17:31 +00:00
"io/ioutil"
"os"
"path"
"testing"
)
func TestMount(t *testing.T) {
2013-11-19 23:24:14 +00:00
graph, driver := tempGraph(t)
2013-11-14 23:17:31 +00:00
defer os.RemoveAll(graph.Root)
2013-11-19 23:24:14 +00:00
defer driver.Cleanup()
2013-11-14 23:17:31 +00:00
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)
}
2013-11-19 23:24:14 +00:00
if _, err := driver.Get(image.ID); err != nil {
2013-11-14 23:17:31 +00:00
t.Fatal(err)
}
}
//FIXME: duplicate
2013-11-19 23:24:14 +00:00
func tempGraph(t *testing.T) (*docker.Graph, graphdriver.Driver) {
2013-11-14 23:17:31 +00:00
tmp, err := ioutil.TempDir("", "docker-graph-")
if err != nil {
t.Fatal(err)
}
2013-11-19 23:24:14 +00:00
driver, err := graphdriver.New(tmp)
if err != nil {
t.Fatal(err)
}
graph, err := docker.NewGraph(tmp, driver)
2013-11-14 23:17:31 +00:00
if err != nil {
t.Fatal(err)
}
2013-11-19 23:24:14 +00:00
return graph, driver
2013-11-14 23:17:31 +00:00
}