diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-06-18 15:59:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-18 09:59:09 +0200 |
commit | 4e2f1ee58d1aa49f85c3a28a4f96e915f12bdb21 (patch) | |
tree | e2751e1c4673f6a051ef04ca156f428a819fdb66 /tests | |
parent | fc2115b494e9ba7e4cf7a1440404dce53738b514 (diff) | |
download | gitea-4e2f1ee58d1aa49f85c3a28a4f96e915f12bdb21.tar.gz gitea-4e2f1ee58d1aa49f85c3a28a4f96e915f12bdb21.zip |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/e2e/e2e_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_activitypub_person_test.go | 12 | ||||
-rw-r--r-- | tests/integration/api_nodeinfo_test.go | 5 | ||||
-rw-r--r-- | tests/integration/create_no_session_test.go | 5 | ||||
-rw-r--r-- | tests/integration/integration_test.go | 2 | ||||
-rw-r--r-- | tests/integration/repofiles_change_test.go | 14 |
6 files changed, 19 insertions, 21 deletions
diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index fbcb0e7da5..c4b0b62199 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -38,7 +38,7 @@ func TestMain(m *testing.M) { defer cancel() tests.InitTest(false) - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() os.Unsetenv("GIT_AUTHOR_NAME") os.Unsetenv("GIT_AUTHOR_EMAIL") diff --git a/tests/integration/api_activitypub_person_test.go b/tests/integration/api_activitypub_person_test.go index 301cfba172..a1ce802709 100644 --- a/tests/integration/api_activitypub_person_test.go +++ b/tests/integration/api_activitypub_person_test.go @@ -22,10 +22,10 @@ import ( func TestActivityPubPerson(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() }() onGiteaRun(t, func(*testing.T, *url.URL) { @@ -60,10 +60,10 @@ func TestActivityPubPerson(t *testing.T) { func TestActivityPubMissingPerson(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() }() onGiteaRun(t, func(*testing.T, *url.URL) { @@ -75,10 +75,10 @@ func TestActivityPubMissingPerson(t *testing.T) { func TestActivityPubPersonInbox(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() }() srv := httptest.NewServer(c) diff --git a/tests/integration/api_nodeinfo_test.go b/tests/integration/api_nodeinfo_test.go index bc2f11a7f2..158a866091 100644 --- a/tests/integration/api_nodeinfo_test.go +++ b/tests/integration/api_nodeinfo_test.go @@ -4,7 +4,6 @@ package integration import ( - "context" "net/http" "net/url" "testing" @@ -18,10 +17,10 @@ import ( func TestNodeinfo(t *testing.T) { setting.Federation.Enabled = true - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() defer func() { setting.Federation.Enabled = false - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() }() onGiteaRun(t, func(*testing.T, *url.URL) { diff --git a/tests/integration/create_no_session_test.go b/tests/integration/create_no_session_test.go index 9a96ed61fa..535d0d4955 100644 --- a/tests/integration/create_no_session_test.go +++ b/tests/integration/create_no_session_test.go @@ -4,7 +4,6 @@ package integration import ( - "context" "net/http" "net/http/httptest" "os" @@ -57,7 +56,7 @@ func TestSessionFileCreation(t *testing.T) { oldSessionConfig := setting.SessionConfig.ProviderConfig defer func() { setting.SessionConfig.ProviderConfig = oldSessionConfig - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() }() var config session.Options @@ -76,7 +75,7 @@ func TestSessionFileCreation(t *testing.T) { setting.SessionConfig.ProviderConfig = string(newConfigBytes) - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() t.Run("NoSessionOnViewIssue", func(t *testing.T) { defer tests.PrintCurrentTest(t)() diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 27918a9ccc..2318ab9bb9 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -87,7 +87,7 @@ func TestMain(m *testing.M) { defer cancel() tests.InitTest(true) - c = routers.NormalRoutes(context.TODO()) + c = routers.NormalRoutes() // integration test settings... if setting.CfgProvider != nil { diff --git a/tests/integration/repofiles_change_test.go b/tests/integration/repofiles_change_test.go index a257b95a84..c273d38188 100644 --- a/tests/integration/repofiles_change_test.go +++ b/tests/integration/repofiles_change_test.go @@ -244,7 +244,7 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA func TestChangeRepoFilesForCreate(t *testing.T) { // setup onGiteaRun(t, func(t *testing.T, u *url.URL) { - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -281,7 +281,7 @@ func TestChangeRepoFilesForCreate(t *testing.T) { func TestChangeRepoFilesForUpdate(t *testing.T) { // setup onGiteaRun(t, func(t *testing.T, u *url.URL) { - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -315,7 +315,7 @@ func TestChangeRepoFilesForUpdate(t *testing.T) { func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) { // setup onGiteaRun(t, func(t *testing.T, u *url.URL) { - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -366,7 +366,7 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) { func TestChangeRepoFilesWithoutBranchNames(t *testing.T) { // setup onGiteaRun(t, func(t *testing.T, u *url.URL) { - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -402,7 +402,7 @@ func TestChangeRepoFilesForDelete(t *testing.T) { func testDeleteRepoFiles(t *testing.T, u *url.URL) { // setup unittest.PrepareTestEnv(t) - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -441,7 +441,7 @@ func TestChangeRepoFilesForDeleteWithoutBranchNames(t *testing.T) { func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) { // setup unittest.PrepareTestEnv(t) - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) @@ -471,7 +471,7 @@ func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) { func TestChangeRepoFilesErrors(t *testing.T) { // setup onGiteaRun(t, func(t *testing.T, u *url.URL) { - ctx := test.MockContext(t, "user2/repo1") + ctx, _ := test.MockContext(t, "user2/repo1") ctx.SetParams(":id", "1") test.LoadRepo(t, ctx, 1) test.LoadRepoCommit(t, ctx) |