Merge pull request #12567 from brahmaroutu/integration_test6_12255

moving integration tests to graph unit tests
This commit is contained in:
Alexander Morozov 2015-04-21 13:58:02 -07:00
commit 7ba8c3b26f
1 changed files with 17 additions and 30 deletions

View File

@ -1,4 +1,4 @@
package docker package graph
import ( import (
"errors" "errors"
@ -11,9 +11,7 @@ import (
"github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/autogen/dockerversion"
"github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/graph"
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
) )
@ -47,6 +45,7 @@ func TestMount(t *testing.T) {
if _, err := driver.Get(image.ID, ""); err != nil { if _, err := driver.Get(image.ID, ""); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
@ -166,18 +165,6 @@ func TestDeletePrefix(t *testing.T) {
assertNImages(graph, t, 0) assertNImages(graph, t, 0)
} }
func createTestImage(graph *graph.Graph, t *testing.T) *image.Image {
archive, err := fakeTar()
if err != nil {
t.Fatal(err)
}
img, err := graph.Create(archive, "", "", "Test image", "", nil, nil)
if err != nil {
t.Fatal(err)
}
return img
}
func TestDelete(t *testing.T) { func TestDelete(t *testing.T) {
graph, _ := tempGraph(t) graph, _ := tempGraph(t)
defer nukeGraph(graph) defer nukeGraph(graph)
@ -277,11 +264,19 @@ func TestByParent(t *testing.T) {
} }
} }
/* func createTestImage(graph *Graph, t *testing.T) *image.Image {
* HELPER FUNCTIONS archive, err := fakeTar()
*/ if err != nil {
t.Fatal(err)
}
img, err := graph.Create(archive, "", "", "Test image", "", nil, nil)
if err != nil {
t.Fatal(err)
}
return img
}
func assertNImages(graph *graph.Graph, t *testing.T, n int) { func assertNImages(graph *Graph, t *testing.T, n int) {
if images, err := graph.Map(); err != nil { if images, err := graph.Map(); err != nil {
t.Fatal(err) t.Fatal(err)
} else if actualN := len(images); actualN != n { } else if actualN := len(images); actualN != n {
@ -289,7 +284,7 @@ func assertNImages(graph *graph.Graph, t *testing.T, n int) {
} }
} }
func tempGraph(t *testing.T) (*graph.Graph, graphdriver.Driver) { func tempGraph(t *testing.T) (*Graph, graphdriver.Driver) {
tmp, err := ioutil.TempDir("", "docker-graph-") tmp, err := ioutil.TempDir("", "docker-graph-")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -298,22 +293,14 @@ func tempGraph(t *testing.T) (*graph.Graph, graphdriver.Driver) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
graph, err := graph.NewGraph(tmp, driver) graph, err := NewGraph(tmp, driver)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
return graph, driver return graph, driver
} }
func nukeGraph(graph *graph.Graph) { func nukeGraph(graph *Graph) {
graph.Driver().Cleanup() graph.Driver().Cleanup()
os.RemoveAll(graph.Root) os.RemoveAll(graph.Root)
} }
func testArchive(t *testing.T) archive.Archive {
archive, err := fakeTar()
if err != nil {
t.Fatal(err)
}
return archive
}