forked from forgejo/forgejo
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
This commit is contained in:
parent
fcb4941d47
commit
e8aae43f56
21 changed files with 244 additions and 244 deletions
|
@ -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")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue