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

View file

@ -1,4 +1,4 @@
package docker
package graph
import (
"errors"
@ -11,9 +11,7 @@ import (
"github.com/docker/docker/autogen/dockerversion"
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/graph"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/stringid"
)
@ -47,6 +45,7 @@ func TestMount(t *testing.T) {
if _, err := driver.Get(image.ID, ""); err != nil {
t.Fatal(err)
}
}
func TestInit(t *testing.T) {
@ -166,18 +165,6 @@ func TestDeletePrefix(t *testing.T) {
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) {
graph, _ := tempGraph(t)
defer nukeGraph(graph)
@ -277,11 +264,19 @@ func TestByParent(t *testing.T) {
}
}
/*
* HELPER FUNCTIONS
*/
func createTestImage(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 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 {
t.Fatal(err)
} 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-")
if err != nil {
t.Fatal(err)
@ -298,22 +293,14 @@ func tempGraph(t *testing.T) (*graph.Graph, graphdriver.Driver) {
if err != nil {
t.Fatal(err)
}
graph, err := graph.NewGraph(tmp, driver)
graph, err := NewGraph(tmp, driver)
if err != nil {
t.Fatal(err)
}
return graph, driver
}
func nukeGraph(graph *graph.Graph) {
func nukeGraph(graph *Graph) {
graph.Driver().Cleanup()
os.RemoveAll(graph.Root)
}
func testArchive(t *testing.T) archive.Archive {
archive, err := fakeTar()
if err != nil {
t.Fatal(err)
}
return archive
}