aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/settings_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-19 19:49:59 +0800
committerGitHub <noreply@github.com>2021-09-19 19:49:59 +0800
commita4bfef265d9e512830350635a0489c2cdcd6508f (patch)
tree1e3c2ec94276dfcb2f8ba73a2ac075ba39c4a34a /routers/web/repo/settings_test.go
parent462306e263db5a809dbe2cdf62e99307aeff28de (diff)
downloadgitea-a4bfef265d9e512830350635a0489c2cdcd6508f.tar.gz
gitea-a4bfef265d9e512830350635a0489c2cdcd6508f.zip
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/web/repo/settings_test.go')
-rw-r--r--routers/web/repo/settings_test.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/routers/web/repo/settings_test.go b/routers/web/repo/settings_test.go
index 5190f12d5d..f9986e44ed 100644
--- a/routers/web/repo/settings_test.go
+++ b/routers/web/repo/settings_test.go
@@ -10,6 +10,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
@@ -42,7 +43,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
} else {
return
}
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/settings/keys")
@@ -57,7 +58,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
DeployKeysPost(ctx)
assert.EqualValues(t, http.StatusFound, ctx.Resp.Status())
- models.AssertExistsAndLoadBean(t, &models.DeployKey{
+ db.AssertExistsAndLoadBean(t, &models.DeployKey{
Name: addKeyForm.Title,
Content: addKeyForm.Content,
Mode: models.AccessModeRead,
@@ -71,7 +72,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
return
}
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/settings/keys")
@@ -87,7 +88,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
DeployKeysPost(ctx)
assert.EqualValues(t, http.StatusFound, ctx.Resp.Status())
- models.AssertExistsAndLoadBean(t, &models.DeployKey{
+ db.AssertExistsAndLoadBean(t, &models.DeployKey{
Name: addKeyForm.Title,
Content: addKeyForm.Content,
Mode: models.AccessModeWrite,
@@ -96,7 +97,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
func TestCollaborationPost(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 4)
@@ -132,7 +133,7 @@ func TestCollaborationPost(t *testing.T) {
func TestCollaborationPost_InactiveUser(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 9)
@@ -156,7 +157,7 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 4)
@@ -198,7 +199,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
func TestCollaborationPost_NonExistentUser(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadRepo(t, ctx, 1)
@@ -220,7 +221,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) {
}
func TestAddTeamPost(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -260,7 +261,7 @@ func TestAddTeamPost(t *testing.T) {
}
func TestAddTeamPost_NotAllowed(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -301,7 +302,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
}
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team11")
@@ -342,7 +343,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
}
func TestAddTeamPost_NonExistentTeam(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "org26/repo43")
ctx.Req.Form.Set("team", "team-non-existent")
@@ -375,7 +376,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) {
}
func TestDeleteTeam(t *testing.T) {
- models.PrepareTestEnv(t)
+ db.PrepareTestEnv(t)
ctx := test.MockContext(t, "org3/team1/repo3")
ctx.Req.Form.Set("id", "2")