1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

fix tests

This commit is contained in:
Victor Vieux 2013-07-24 12:28:22 +00:00
parent 4bc3328e80
commit f4b41e1a6c
3 changed files with 10 additions and 7 deletions

2
api.go
View file

@ -179,7 +179,7 @@ func getInfo(srv *Server, version float64, w http.ResponseWriter, r *http.Reques
} }
func getEvents(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { func getEvents(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
sendEvent := func(wf *utils.WriteFlusher, event *utils.JSONMessage) (error) { sendEvent := func(wf *utils.WriteFlusher, event *utils.JSONMessage) error {
b, err := json.Marshal(event) b, err := json.Marshal(event)
if err != nil { if err != nil {
return fmt.Errorf("JSON error") return fmt.Errorf("JSON error")

View file

@ -102,6 +102,7 @@ func LoadConfig(rootPath string) (*ConfigFile, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
authConfig.Auth = ""
configFile.Configs[k] = authConfig configFile.Configs[k] = authConfig
} }
} }

View file

@ -11,7 +11,9 @@ import (
func TestEncodeAuth(t *testing.T) { func TestEncodeAuth(t *testing.T) {
newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"} newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"}
authStr := encodeAuth(newAuthConfig) authStr := encodeAuth(newAuthConfig)
decAuthConfig, err := decodeAuth(authStr) decAuthConfig := &AuthConfig{}
var err error
decAuthConfig.Username, decAuthConfig.Password, err = decodeAuth(authStr)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -29,8 +31,8 @@ func TestEncodeAuth(t *testing.T) {
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com")
defer os.Setenv("DOCKER_INDEX_URL", "") defer os.Setenv("DOCKER_INDEX_URL", "")
authConfig := NewAuthConfig("unittester", "surlautrerivejetattendrai", "noise+unittester@dotcloud.com", "/tmp") authConfig := &AuthConfig{Username: "unittester", Password: "surlautrerivejetattendrai", Email: "noise+unittester@dotcloud.com"}
status, err := Login(authConfig, false) status, err := Login(authConfig)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -49,8 +51,8 @@ func TestCreateAccount(t *testing.T) {
} }
token := hex.EncodeToString(tokenBuffer)[:12] token := hex.EncodeToString(tokenBuffer)[:12]
username := "ut" + token username := "ut" + token
authConfig := NewAuthConfig(username, "test42", "docker-ut+"+token+"@example.com", "/tmp") authConfig := &AuthConfig{Username: username, Password: "test42", Email: "docker-ut+"+token+"@example.com"}
status, err := Login(authConfig, false) status, err := Login(authConfig)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -60,7 +62,7 @@ func TestCreateAccount(t *testing.T) {
t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status) t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status)
} }
status, err = Login(authConfig, false) status, err = Login(authConfig)
if err == nil { if err == nil {
t.Fatalf("Expected error but found nil instead") t.Fatalf("Expected error but found nil instead")
} }