mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 03:14:15 +03:00
parent
7888a55e8c
commit
084797b4dc
2 changed files with 4 additions and 4 deletions
|
@ -27,7 +27,7 @@ func TestMain(m *testing.M) {
|
||||||
func TestHasOwnerPackages(t *testing.T) {
|
func TestHasOwnerPackages(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).(*user_model.User)
|
||||||
|
|
||||||
p, err := packages_model.TryInsertPackage(db.DefaultContext, &packages_model.Package{
|
p, err := packages_model.TryInsertPackage(db.DefaultContext, &packages_model.Package{
|
||||||
OwnerID: owner.ID,
|
OwnerID: owner.ID,
|
||||||
|
|
|
@ -100,9 +100,9 @@ func DeleteUser(ctx context.Context, u *user_model.User) (err error) {
|
||||||
|
|
||||||
// Delete Comments
|
// Delete Comments
|
||||||
const batchSize = 50
|
const batchSize = 50
|
||||||
for start := 0; ; start += batchSize {
|
for {
|
||||||
comments := make([]*issues_model.Comment, 0, batchSize)
|
comments := make([]*issues_model.Comment, 0, batchSize)
|
||||||
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, start).Find(&comments); err != nil {
|
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, 0).Find(&comments); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(comments) == 0 {
|
if len(comments) == 0 {
|
||||||
|
@ -200,7 +200,7 @@ func DeleteUser(ctx context.Context, u *user_model.User) (err error) {
|
||||||
// ***** END: ExternalLoginUser *****
|
// ***** END: ExternalLoginUser *****
|
||||||
|
|
||||||
if _, err = e.ID(u.ID).Delete(new(user_model.User)); err != nil {
|
if _, err = e.ID(u.ID).Delete(new(user_model.User)); err != nil {
|
||||||
return fmt.Errorf("Delete: %v", err)
|
return fmt.Errorf("delete: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue