1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix unit-tests

This commit is contained in:
Guillaume J. Charmes 2013-11-19 15:24:14 -08:00
parent 28d4cbbc59
commit 12e993549d
No known key found for this signature in database
GPG key ID: B33E4642CB6E3FF3
4 changed files with 23 additions and 83 deletions

View file

@ -2,6 +2,7 @@ package docker
import (
"github.com/dotcloud/docker"
"github.com/dotcloud/docker/graphdriver"
"io/ioutil"
"os"
"path"
@ -9,8 +10,10 @@ import (
)
func TestMount(t *testing.T) {
graph := tempGraph(t)
graph, driver := tempGraph(t)
defer os.RemoveAll(graph.Root)
defer driver.Cleanup()
archive, err := fakeTar()
if err != nil {
t.Fatal(err)
@ -32,26 +35,25 @@ func TestMount(t *testing.T) {
if err := os.MkdirAll(rw, 0700); err != nil {
t.Fatal(err)
}
if err := image.Mount(rootfs, rw); err != nil {
if _, err := driver.Get(image.ID); 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 {
func tempGraph(t *testing.T) (*docker.Graph, graphdriver.Driver) {
tmp, err := ioutil.TempDir("", "docker-graph-")
if err != nil {
t.Fatal(err)
}
graph, err := docker.NewGraph(tmp)
driver, err := graphdriver.New(tmp)
if err != nil {
t.Fatal(err)
}
return graph
graph, err := docker.NewGraph(tmp, driver)
if err != nil {
t.Fatal(err)
}
return graph, driver
}