diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-09-01 13:26:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-01 13:26:07 +0200 |
commit | e8aae43f56fedd6f7b04affd378c2c4ed2af9d78 (patch) | |
tree | a9b03cbf3f926f2cd27eb4d3c18126aec1cc7aa9 /routers/web/repo/setting/settings_test.go | |
parent | Remove some unused CSS styles (#26852) (diff) | |
download | forgejo-e8aae43f56fedd6f7b04affd378c2c4ed2af9d78.tar.xz forgejo-e8aae43f56fedd6f7b04affd378c2c4ed2af9d78.zip |
Move web/api context related testing function into a separate package (#26859)
Just like `models/unittest`, the testing helper functions should be in a
separate package: `contexttest`
And complete the TODO:
> // TODO: move this function to other packages, because it depends on
"models" package
Diffstat (limited to 'routers/web/repo/setting/settings_test.go')
-rw-r--r-- | routers/web/repo/setting/settings_test.go | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/routers/web/repo/setting/settings_test.go b/routers/web/repo/setting/settings_test.go index 6f7c844ce7..51d127bfc2 100644 --- a/routers/web/repo/setting/settings_test.go +++ b/routers/web/repo/setting/settings_test.go @@ -15,8 +15,8 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/contexttest" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/forms" @@ -42,10 +42,10 @@ func TestAddReadOnlyDeployKey(t *testing.T) { } unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/settings/keys") + ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys") - test.LoadUser(t, ctx, 2) - test.LoadRepo(t, ctx, 2) + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadRepo(t, ctx, 2) addKeyForm := forms.AddKeyForm{ Title: "read-only", @@ -71,10 +71,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/settings/keys") + ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys") - test.LoadUser(t, ctx, 2) - test.LoadRepo(t, ctx, 2) + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadRepo(t, ctx, 2) addKeyForm := forms.AddKeyForm{ Title: "read-write", @@ -94,10 +94,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) { func TestCollaborationPost(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/issues/labels") - test.LoadUser(t, ctx, 2) - test.LoadUser(t, ctx, 4) - test.LoadRepo(t, ctx, 1) + ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels") + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadUser(t, ctx, 4) + contexttest.LoadRepo(t, ctx, 1) ctx.Req.Form.Set("collaborator", "user4") @@ -129,10 +129,10 @@ func TestCollaborationPost(t *testing.T) { func TestCollaborationPost_InactiveUser(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/issues/labels") - test.LoadUser(t, ctx, 2) - test.LoadUser(t, ctx, 9) - test.LoadRepo(t, ctx, 1) + ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels") + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadUser(t, ctx, 9) + contexttest.LoadRepo(t, ctx, 1) ctx.Req.Form.Set("collaborator", "user9") @@ -152,10 +152,10 @@ func TestCollaborationPost_InactiveUser(t *testing.T) { func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/issues/labels") - test.LoadUser(t, ctx, 2) - test.LoadUser(t, ctx, 4) - test.LoadRepo(t, ctx, 1) + ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels") + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadUser(t, ctx, 4) + contexttest.LoadRepo(t, ctx, 1) ctx.Req.Form.Set("collaborator", "user4") @@ -193,9 +193,9 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) { func TestCollaborationPost_NonExistentUser(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "user2/repo1/issues/labels") - test.LoadUser(t, ctx, 2) - test.LoadRepo(t, ctx, 1) + ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels") + contexttest.LoadUser(t, ctx, 2) + contexttest.LoadRepo(t, ctx, 1) ctx.Req.Form.Set("collaborator", "user34") @@ -215,7 +215,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) { func TestAddTeamPost(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "org26/repo43") + ctx, _ := contexttest.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -255,7 +255,7 @@ func TestAddTeamPost(t *testing.T) { func TestAddTeamPost_NotAllowed(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "org26/repo43") + ctx, _ := contexttest.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -295,7 +295,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) { func TestAddTeamPost_AddTeamTwice(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "org26/repo43") + ctx, _ := contexttest.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -336,7 +336,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) { func TestAddTeamPost_NonExistentTeam(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "org26/repo43") + ctx, _ := contexttest.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team-non-existent") @@ -369,7 +369,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) { func TestDeleteTeam(t *testing.T) { unittest.PrepareTestEnv(t) - ctx, _ := test.MockContext(t, "org3/team1/repo3") + ctx, _ := contexttest.MockContext(t, "org3/team1/repo3") ctx.Req.Form.Set("id", "2") |