1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-18 14:48:13 +00:00

Fix context usages (#35348)

This commit is contained in:
wxiaoguang
2025-08-27 19:00:01 +08:00
committed by GitHub
parent da5ce5c8e7
commit e837c998b7
48 changed files with 98 additions and 100 deletions

View File

@@ -43,7 +43,7 @@ func TestAPIPullReview(t *testing.T) {
require.Len(t, reviews, 8)
for _, r := range reviews {
assert.Equal(t, pullIssue.HTMLURL(), r.HTMLPullURL)
assert.Equal(t, pullIssue.HTMLURL(t.Context()), r.HTMLPullURL)
}
assert.EqualValues(t, 8, reviews[3].ID)
assert.EqualValues(t, "APPROVED", reviews[3].State)

View File

@@ -56,7 +56,7 @@ func initMigrationTest(t *testing.T) func() {
assert.NotEmpty(t, setting.RepoRootPath)
assert.NoError(t, unittest.SyncDirs(filepath.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath))
assert.NoError(t, git.InitFull(t.Context()))
assert.NoError(t, git.InitFull())
setting.LoadDBSetting()
setting.InitLoggersForTest()

View File

@@ -50,7 +50,7 @@ func TestWebfinger(t *testing.T) {
var jrd webfingerJRD
DecodeJSON(t, resp, &jrd)
assert.Equal(t, "acct:user2@"+appURL.Host, jrd.Subject)
assert.ElementsMatch(t, []string{user.HTMLURL(), appURL.String() + "api/v1/activitypub/user-id/" + strconv.FormatInt(user.ID, 10)}, jrd.Aliases)
assert.ElementsMatch(t, []string{user.HTMLURL(t.Context()), appURL.String() + "api/v1/activitypub/user-id/" + strconv.FormatInt(user.ID, 10)}, jrd.Aliases)
req = NewRequest(t, "GET", fmt.Sprintf("/.well-known/webfinger?resource=acct:%s@%s", user.LowerName, "unknown.host"))
MakeRequest(t, req, http.StatusBadRequest)

View File

@@ -4,7 +4,6 @@
package tests
import (
"context"
"database/sql"
"fmt"
"os"
@@ -68,7 +67,7 @@ func InitTest(requireGitea bool) {
unittest.InitSettingsForTesting()
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
if err := git.InitFull(context.Background()); err != nil {
if err := git.InitFull(); err != nil {
log.Fatal("git.InitOnceWithSync: %v", err)
}