aboutsummaryrefslogtreecommitdiff
path: root/internal/route/api/v1/user
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-18 12:07:30 +0800
committerGitHub <noreply@github.com>2020-04-18 12:07:30 +0800
commit9d64d222a8c30db5076a591981ad7cfe672ba6f1 (patch)
treec753eb898a1ead0afbe5b6a7a28b466ab0d2b8ac /internal/route/api/v1/user
parentfa497b16332c24bc4d9e788c64bda94e3c1499a7 (diff)
db: add tests for users (#6116)
* Add new methods * Use Users.Create to replace previous hack * Reduce side effect * Do not clear tables when test failed * test_users_Authenticate * Rename constant * test_users_Create * test_users_GetByEmail * test_users_GetByID * test_users_GetByUsername
Diffstat (limited to 'internal/route/api/v1/user')
-rw-r--r--internal/route/api/v1/user/email.go2
-rw-r--r--internal/route/api/v1/user/user.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/internal/route/api/v1/user/email.go b/internal/route/api/v1/user/email.go
index 07fd4f8a..5584803e 100644
--- a/internal/route/api/v1/user/email.go
+++ b/internal/route/api/v1/user/email.go
@@ -46,7 +46,7 @@ func AddEmail(c *context.APIContext, form api.CreateEmailOption) {
if err := db.AddEmailAddresses(emails); err != nil {
if db.IsErrEmailAlreadyUsed(err) {
- c.ErrorStatus(http.StatusUnprocessableEntity, errors.New("email address has been used: "+err.(db.ErrEmailAlreadyUsed).Email))
+ c.ErrorStatus(http.StatusUnprocessableEntity, errors.New("email address has been used: "+err.(db.ErrEmailAlreadyUsed).Email()))
} else {
c.Error(err, "add email addresses")
}
diff --git a/internal/route/api/v1/user/user.go b/internal/route/api/v1/user/user.go
index 695d5311..c57f8fed 100644
--- a/internal/route/api/v1/user/user.go
+++ b/internal/route/api/v1/user/user.go
@@ -19,7 +19,7 @@ import (
func Search(c *context.APIContext) {
opts := &db.SearchUserOptions{
Keyword: c.Query("q"),
- Type: db.USER_TYPE_INDIVIDUAL,
+ Type: db.UserIndividual,
PageSize: com.StrTo(c.Query("limit")).MustInt(),
}
if opts.PageSize == 0 {