moving integration tests to graph unit tests

Addresses #12255
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
Srini Brahmaroutu 2015-04-20 21:07:21 +00:00
Родитель b5584ec24a
Коммит 29c5596176
1 изменённых файлов: 17 добавлений и 30 удалений

Просмотреть файл

@ -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
}