mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-02 12:52:12 +00:00
Refactor web package and context package (#25298)
1. The "web" package shouldn't depends on "modules/context" package, instead, let each "web context" register themselves to the "web" package. 2. The old Init/Free doesn't make sense, so simplify it * The ctx in "Init(ctx)" is never used, and shouldn't be used that way * The "Free" is never called and shouldn't be called because the SSPI instance is shared --------- Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
fc2115b494
commit
4e2f1ee58d
45 changed files with 218 additions and 292 deletions
|
@ -42,7 +42,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
|
|||
}
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 2)
|
||||
|
@ -71,7 +71,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
|||
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 2)
|
||||
|
@ -94,7 +94,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
|||
|
||||
func TestCollaborationPost(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 4)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
@ -129,7 +129,7 @@ func TestCollaborationPost(t *testing.T) {
|
|||
|
||||
func TestCollaborationPost_InactiveUser(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 9)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
@ -152,7 +152,7 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
|
|||
|
||||
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 4)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
@ -193,7 +193,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
|||
|
||||
func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
||||
|
@ -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, _ := test.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, _ := test.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, _ := test.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, _ := test.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, _ := test.MockContext(t, "org3/team1/repo3")
|
||||
|
||||
ctx.Req.Form.Set("id", "2")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue