mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 18:55:18 +01:00
Merge branch 'master' into modify_authentication_of_repository_api
This commit is contained in:
commit
4b27ef7a25
@ -624,6 +624,19 @@ func TestGetAllProjects(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPublicProjects(t *testing.T) {
|
||||
projects, err := GetPublicProjects("")
|
||||
if err != nil {
|
||||
t.Errorf("Error occurred in getProjects: %v", err)
|
||||
}
|
||||
if len(projects) != 1 {
|
||||
t.Errorf("Expected length of projects is 1, but actual: %d, the projects: %+v", len(projects), projects)
|
||||
}
|
||||
if projects[0].Name != "library" {
|
||||
t.Errorf("Expected project name in the list: %s, actual: %s", "library", projects[0].Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddProjectMember(t *testing.T) {
|
||||
err := AddProjectMember(currentProject.ProjectID, 1, models.DEVELOPER)
|
||||
if err != nil {
|
||||
|
@ -221,7 +221,6 @@ func GetPublicProjects(projectName string) ([]models.Project, error) {
|
||||
publicProjects, err := getProjects(1, projectName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
}
|
||||
return publicProjects, nil
|
||||
}
|
||||
@ -242,7 +241,7 @@ func getProjects(public int, projectName string) ([]models.Project, error) {
|
||||
where deleted = 0`
|
||||
queryParam := make([]interface{}, 1)
|
||||
if public == 1 {
|
||||
sql += "and public = ?"
|
||||
sql += " and public = ? "
|
||||
queryParam = append(queryParam, public)
|
||||
}
|
||||
if len(projectName) > 0 {
|
||||
@ -251,6 +250,7 @@ func getProjects(public int, projectName string) ([]models.Project, error) {
|
||||
}
|
||||
sql += " order by name "
|
||||
var projects []models.Project
|
||||
log.Debugf("sql xxx", sql)
|
||||
if _, err := o.Raw(sql, queryParam).QueryRows(&projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user