Browse Source

fix tests

Victor Vieux 12 năm trước cách đây
mục cha
commit
f4b41e1a6c
3 tập tin đã thay đổi với 10 bổ sung7 xóa
  1. 1 1
      api.go
  2. 1 0
      auth/auth.go
  3. 8 6
      auth/auth_test.go

+ 1 - 1
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")

+ 1 - 0
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
 		}
 	}

+ 8 - 6
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")
 	}