summaryrefslogtreecommitdiffstats
path: root/services/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-16 10:22:25 +0800
committerGitHub <noreply@github.com>2022-08-16 10:22:25 +0800
commit86c85c19b625e6ddd99f220a13ee3b5c4cc398e1 (patch)
tree2545e0c31d5e240b1b168041601c2c24db63bae4 /services/user
parente3308a092ad00585607089434b2ec5ec4f07c539 (diff)
downloadgitea-86c85c19b625e6ddd99f220a13ee3b5c4cc398e1.tar.gz
gitea-86c85c19b625e6ddd99f220a13ee3b5c4cc398e1.zip
Refactor AssertExistsAndLoadBean to use generics (#20797)
* Refactor AssertExistsAndLoadBean to use generics * Fix tests Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'services/user')
-rw-r--r--services/user/user_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/services/user/user_test.go b/services/user/user_test.go
index d8673593df..c07244e7e1 100644
--- a/services/user/user_test.go
+++ b/services/user/user_test.go
@@ -28,7 +28,7 @@ func TestMain(m *testing.M) {
func TestDeleteUser(t *testing.T) {
test := func(userID int64) {
assert.NoError(t, unittest.PrepareTestDatabase())
- user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID}).(*user_model.User)
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
ownedRepos := make([]*repo_model.Repository, 0, 10)
assert.NoError(t, db.GetEngine(db.DefaultContext).Find(&ownedRepos, &repo_model.Repository{OwnerID: userID}))
@@ -56,14 +56,14 @@ func TestDeleteUser(t *testing.T) {
test(8)
test(11)
- org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User)
+ org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
assert.Error(t, DeleteUser(db.DefaultContext, org, false))
}
func TestPurgeUser(t *testing.T) {
test := func(userID int64) {
assert.NoError(t, unittest.PrepareTestDatabase())
- user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID}).(*user_model.User)
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
err := DeleteUser(db.DefaultContext, user, true)
assert.NoError(t, err)
@@ -76,7 +76,7 @@ func TestPurgeUser(t *testing.T) {
test(8)
test(11)
- org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User)
+ org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
assert.Error(t, DeleteUser(db.DefaultContext, org, false))
}