summaryrefslogtreecommitdiffstats
path: root/services/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /services/user
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'services/user')
-rw-r--r--services/user/user.go3
-rw-r--r--services/user/user_test.go7
2 files changed, 6 insertions, 4 deletions
diff --git a/services/user/user.go b/services/user/user.go
index 6df9eec131..72052f4ec9 100644
--- a/services/user/user.go
+++ b/services/user/user.go
@@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/models"
admin_model "code.gitea.io/gitea/models/admin"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/avatar"
"code.gitea.io/gitea/modules/log"
@@ -40,7 +41,7 @@ func DeleteUser(u *user_model.User) error {
// cannot perform delete operation.
// Check ownership of repository.
- count, err := models.GetRepositoryCount(ctx, u.ID)
+ count, err := repo_model.GetRepositoryCount(ctx, u.ID)
if err != nil {
return fmt.Errorf("GetRepositoryCount: %v", err)
} else if count > 0 {
diff --git a/services/user/user_test.go b/services/user/user_test.go
index e18b760308..5b35db790c 100644
--- a/services/user/user_test.go
+++ b/services/user/user_test.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
@@ -26,8 +27,8 @@ func TestDeleteUser(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID}).(*user_model.User)
- ownedRepos := make([]*models.Repository, 0, 10)
- assert.NoError(t, db.GetEngine(db.DefaultContext).Find(&ownedRepos, &models.Repository{OwnerID: userID}))
+ ownedRepos := make([]*repo_model.Repository, 0, 10)
+ assert.NoError(t, db.GetEngine(db.DefaultContext).Find(&ownedRepos, &repo_model.Repository{OwnerID: userID}))
if len(ownedRepos) > 0 {
err := DeleteUser(user)
assert.Error(t, err)
@@ -45,7 +46,7 @@ func TestDeleteUser(t *testing.T) {
}
assert.NoError(t, DeleteUser(user))
unittest.AssertNotExistsBean(t, &user_model.User{ID: userID})
- unittest.CheckConsistencyFor(t, &user_model.User{}, &models.Repository{})
+ unittest.CheckConsistencyFor(t, &user_model.User{}, &repo_model.Repository{})
}
test(2)
test(4)