Some checks failed
Build and Release / Create Release (push) Successful in 0s
Trigger Vault Plugin Rebuild / Trigger Vault Rebuild (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Lint (push) Failing after 5m2s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 5m37s
Go's semantic import versioning requires v2+ modules to include the major version in the module path. This enables using proper version tags (v3.x.x) instead of pseudo-versions. Updated module path: code.gitcaddy.com/server/v3
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
issues_model "code.gitcaddy.com/server/v3/models/issues"
|
|
"code.gitcaddy.com/server/v3/models/organization"
|
|
access_model "code.gitcaddy.com/server/v3/models/perm/access"
|
|
repo_model "code.gitcaddy.com/server/v3/models/repo"
|
|
"code.gitcaddy.com/server/v3/models/unittest"
|
|
user_model "code.gitcaddy.com/server/v3/models/user"
|
|
"code.gitcaddy.com/server/v3/tests"
|
|
)
|
|
|
|
func assertUserDeleted(t *testing.T, userID int64) {
|
|
unittest.AssertNotExistsBean(t, &user_model.User{ID: userID})
|
|
unittest.AssertNotExistsBean(t, &user_model.Follow{UserID: userID})
|
|
unittest.AssertNotExistsBean(t, &user_model.Follow{FollowID: userID})
|
|
unittest.AssertNotExistsBean(t, &repo_model.Repository{OwnerID: userID})
|
|
unittest.AssertNotExistsBean(t, &access_model.Access{UserID: userID})
|
|
unittest.AssertNotExistsBean(t, &organization.OrgUser{UID: userID})
|
|
unittest.AssertNotExistsBean(t, &issues_model.IssueUser{UID: userID})
|
|
unittest.AssertNotExistsBean(t, &organization.TeamUser{UID: userID})
|
|
unittest.AssertNotExistsBean(t, &repo_model.Star{UID: userID})
|
|
}
|
|
|
|
func TestUserDeleteAccount(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
session := loginUser(t, "user8")
|
|
urlStr := "/user/settings/account/delete?password=" + userPassword
|
|
req := NewRequest(t, "POST", urlStr)
|
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
|
|
|
assertUserDeleted(t, 8)
|
|
unittest.CheckConsistencyFor(t, &user_model.User{})
|
|
}
|
|
|
|
func TestUserDeleteAccountStillOwnRepos(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
session := loginUser(t, "user2")
|
|
urlStr := "/user/settings/account/delete?password=" + userPassword
|
|
req := NewRequest(t, "POST", urlStr)
|
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
|
|
|
// user should not have been deleted, because the user still owns repos
|
|
unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
}
|