Update tests to reflect new project structure

This commit is contained in:
Guillaume J. Charmes 2013-05-15 01:52:09 +00:00
parent 9bb3dc9843
commit e7077320ff
5 changed files with 17 additions and 7 deletions

View File

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

View File

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

View File

@ -4,6 +4,7 @@ import (
"archive/tar" "archive/tar"
"bytes" "bytes"
"errors" "errors"
"github.com/dotcloud/docker/utils"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
@ -155,7 +156,7 @@ func TestDeletePrefix(t *testing.T) {
graph := tempGraph(t) graph := tempGraph(t)
defer os.RemoveAll(graph.Root) defer os.RemoveAll(graph.Root)
img := createTestImage(graph, t) 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) t.Fatal(err)
} }
assertNImages(graph, t, 0) assertNImages(graph, t, 0)

View File

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

View File

@ -151,10 +151,10 @@ func SelfPath() string {
return path 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 return len(buf), nil
} }