From f4b41e1a6c2c5d531451bf2feeb3877e03eb8c1c Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 24 Jul 2013 12:28:22 +0000 Subject: [PATCH] fix tests --- api.go | 2 +- auth/auth.go | 1 + auth/auth_test.go | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api.go b/api.go index 94c1a3b8d2..834c41a68c 100644 --- a/api.go +++ b/api.go @@ -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 { - sendEvent := func(wf *utils.WriteFlusher, event *utils.JSONMessage) (error) { + sendEvent := func(wf *utils.WriteFlusher, event *utils.JSONMessage) error { b, err := json.Marshal(event) if err != nil { return fmt.Errorf("JSON error") diff --git a/auth/auth.go b/auth/auth.go index 8f4d09fb8f..bffed49807 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -102,6 +102,7 @@ func LoadConfig(rootPath string) (*ConfigFile, error) { if err != nil { return nil, err } + authConfig.Auth = "" configFile.Configs[k] = authConfig } } diff --git a/auth/auth_test.go b/auth/auth_test.go index d036de7364..458a505ea2 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -11,7 +11,9 @@ import ( func TestEncodeAuth(t *testing.T) { newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"} authStr := encodeAuth(newAuthConfig) - decAuthConfig, err := decodeAuth(authStr) + decAuthConfig := &AuthConfig{} + var err error + decAuthConfig.Username, decAuthConfig.Password, err = decodeAuth(authStr) if err != nil { t.Fatal(err) } @@ -29,8 +31,8 @@ func TestEncodeAuth(t *testing.T) { func TestLogin(t *testing.T) { os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") defer os.Setenv("DOCKER_INDEX_URL", "") - authConfig := NewAuthConfig("unittester", "surlautrerivejetattendrai", "noise+unittester@dotcloud.com", "/tmp") - status, err := Login(authConfig, false) + authConfig := &AuthConfig{Username: "unittester", Password: "surlautrerivejetattendrai", Email: "noise+unittester@dotcloud.com"} + status, err := Login(authConfig) if err != nil { t.Fatal(err) } @@ -49,8 +51,8 @@ func TestCreateAccount(t *testing.T) { } token := hex.EncodeToString(tokenBuffer)[:12] username := "ut" + token - authConfig := NewAuthConfig(username, "test42", "docker-ut+"+token+"@example.com", "/tmp") - status, err := Login(authConfig, false) + authConfig := &AuthConfig{Username: username, Password: "test42", Email: "docker-ut+"+token+"@example.com"} + status, err := Login(authConfig) if err != nil { t.Fatal(err) } @@ -60,7 +62,7 @@ func TestCreateAccount(t *testing.T) { t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status) } - status, err = Login(authConfig, false) + status, err = Login(authConfig) if err == nil { t.Fatalf("Expected error but found nil instead") }