This commit is contained in:
Wenkai Yin 2017-04-24 15:33:43 +08:00
parent 3038790faa
commit b9833990c4
2 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/astaxie/beego/orm"
//"github.com/vmware/harbor/src/common/config"
"github.com/stretchr/testify/assert"
"github.com/vmware/harbor/src/common/models"
"github.com/vmware/harbor/src/common/utils"
"github.com/vmware/harbor/src/common/utils/log"
@ -402,6 +403,10 @@ func TestGetUser(t *testing.T) {
if currentUser.Email != "tester01@vmware.com" {
t.Errorf("the user's email does not match, expected: tester01@vmware.com, actual: %s", currentUser.Email)
}
queryUser = models.User{}
_, err = GetUser(queryUser)
assert.NotNil(t, err)
}
func TestListUsers(t *testing.T) {

View File

@ -60,6 +60,10 @@ func GetUser(query models.User) (*models.User, error) {
return nil, nil
}
if n > 1 {
return nil, fmt.Errorf("got more than one user when executing: %s param: %v", sql, queryParam)
}
return &u[0], nil
}