Explorar o código

Update tests to reflect new project structure

Guillaume J. Charmes %!s(int64=12) %!d(string=hai) anos
pai
achega
e7077320ff
Modificáronse 5 ficheiros con 17 adicións e 7 borrados
  1. 6 1
      api_test.go
  2. 2 1
      builder_test.go
  3. 2 1
      graph_test.go
  4. 5 2
      runtime_test.go
  5. 2 2
      utils/utils.go

+ 6 - 1
api_test.go

@@ -6,6 +6,8 @@ import (
 	"bytes"
 	"encoding/json"
 	"github.com/dotcloud/docker/auth"
+	"github.com/dotcloud/docker/registry"
+	"github.com/dotcloud/docker/utils"
 	"io"
 	"net"
 	"net/http"
@@ -222,7 +224,10 @@ func TestGetImagesSearch(t *testing.T) {
 	}
 	defer nuke(runtime)
 
-	srv := &Server{runtime: runtime}
+	srv := &Server{
+		runtime:  runtime,
+		registry: registry.NewRegistry(runtime.authConfig),
+	}
 
 	r := httptest.NewRecorder()
 

+ 2 - 1
builder_test.go

@@ -1,6 +1,7 @@
 package docker
 
 import (
+	"github.com/dotcloud/docker/utils"
 	"strings"
 	"testing"
 )
@@ -24,7 +25,7 @@ func TestBuild(t *testing.T) {
 
 	builder := NewBuilder(runtime)
 
-	img, err := builder.Build(strings.NewReader(Dockerfile), &nopWriter{})
+	img, err := builder.Build(strings.NewReader(Dockerfile), &utils.NopWriter{})
 	if err != nil {
 		t.Fatal(err)
 	}

+ 2 - 1
graph_test.go

@@ -4,6 +4,7 @@ import (
 	"archive/tar"
 	"bytes"
 	"errors"
+	"github.com/dotcloud/docker/utils"
 	"io"
 	"io/ioutil"
 	"os"
@@ -155,7 +156,7 @@ func TestDeletePrefix(t *testing.T) {
 	graph := tempGraph(t)
 	defer os.RemoveAll(graph.Root)
 	img := createTestImage(graph, t)
-	if err := graph.Delete(TruncateId(img.Id)); err != nil {
+	if err := graph.Delete(utils.TruncateId(img.Id)); err != nil {
 		t.Fatal(err)
 	}
 	assertNImages(graph, t, 0)

+ 5 - 2
runtime_test.go

@@ -2,6 +2,8 @@ package docker
 
 import (
 	"fmt"
+	"github.com/dotcloud/docker/registry"
+	"github.com/dotcloud/docker/utils"
 	"io"
 	"io/ioutil"
 	"net"
@@ -48,7 +50,7 @@ func layerArchive(tarfile string) (io.Reader, error) {
 
 func init() {
 	// Hack to run sys init during unit testing
-	if SelfPath() == "/sbin/init" {
+	if utils.SelfPath() == "/sbin/init" {
 		SysInit()
 		return
 	}
@@ -69,7 +71,8 @@ func init() {
 
 	// Create the "Server"
 	srv := &Server{
-		runtime: runtime,
+		runtime:  runtime,
+		registry: registry.NewRegistry(runtime.authConfig),
 	}
 	// Retrieve the Image
 	if err := srv.ImagePull(unitTestImageName, "", "", os.Stdout); err != nil {

+ 2 - 2
utils/utils.go

@@ -151,10 +151,10 @@ func SelfPath() string {
 	return path
 }
 
-type nopWriter struct {
+type NopWriter struct {
 }
 
-func (w *nopWriter) Write(buf []byte) (int, error) {
+func (w *NopWriter) Write(buf []byte) (int, error) {
 	return len(buf), nil
 }