1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Use test context in tests and new loop system in benchmarks (#33648)

Replace all contexts in tests with go1.24 t.Context()

---------

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-02-20 10:57:40 +01:00
committed by GitHub
parent 3bbc482879
commit cc1fdc84ca
108 changed files with 712 additions and 794 deletions

View File

@@ -4,7 +4,6 @@
package actions
import (
"context"
"testing"
actions_model "code.gitea.io/gitea/models/actions"
@@ -19,7 +18,7 @@ func TestFindTaskNeeds(t *testing.T) {
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 51})
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: task.JobID})
ret, err := FindTaskNeeds(context.Background(), job)
ret, err := FindTaskNeeds(t.Context(), job)
assert.NoError(t, err)
assert.Len(t, ret, 1)
assert.Contains(t, ret, "job1")

View File

@@ -4,7 +4,6 @@
package auth
import (
"context"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -26,7 +25,7 @@ func TestUserIDFromToken(t *testing.T) {
ds := make(reqctx.ContextData)
o := OAuth2{}
uid := o.userIDFromToken(context.Background(), token, ds)
uid := o.userIDFromToken(t.Context(), token, ds)
assert.Equal(t, int64(user_model.ActionsUserID), uid)
assert.Equal(t, true, ds["IsActionsToken"])
assert.Equal(t, ds["ActionsTaskID"], int64(RunningTaskID))
@@ -48,7 +47,7 @@ func TestCheckTaskIsRunning(t *testing.T) {
for name := range cases {
c := cases[name]
t.Run(name, func(t *testing.T) {
actual := CheckTaskIsRunning(context.Background(), c.TaskID)
actual := CheckTaskIsRunning(t.Context(), c.TaskID)
assert.Equal(t, c.Expected, actual)
})
}

View File

@@ -4,7 +4,6 @@
package oauth2
import (
"context"
"testing"
"code.gitea.io/gitea/models/auth"
@@ -36,7 +35,7 @@ func TestSource(t *testing.T) {
Email: "external@example.com",
}
err := user_model.CreateUser(context.Background(), user, &user_model.Meta{}, &user_model.CreateUserOverwriteOptions{})
err := user_model.CreateUser(t.Context(), user, &user_model.Meta{}, &user_model.CreateUserOverwriteOptions{})
assert.NoError(t, err)
e := &user_model.ExternalLoginUser{
@@ -45,7 +44,7 @@ func TestSource(t *testing.T) {
LoginSourceID: user.LoginSource,
RefreshToken: "valid",
}
err = user_model.LinkExternalToUser(context.Background(), user, e)
err = user_model.LinkExternalToUser(t.Context(), user, e)
assert.NoError(t, err)
provider, err := createProvider(source.authSource.Name, source)
@@ -53,7 +52,7 @@ func TestSource(t *testing.T) {
t.Run("refresh", func(t *testing.T) {
t.Run("valid", func(t *testing.T) {
err := source.refresh(context.Background(), provider, e)
err := source.refresh(t.Context(), provider, e)
assert.NoError(t, err)
e := &user_model.ExternalLoginUser{
@@ -61,19 +60,19 @@ func TestSource(t *testing.T) {
LoginSourceID: e.LoginSourceID,
}
ok, err := user_model.GetExternalLogin(context.Background(), e)
ok, err := user_model.GetExternalLogin(t.Context(), e)
assert.NoError(t, err)
assert.True(t, ok)
assert.Equal(t, "refresh", e.RefreshToken)
assert.Equal(t, "token", e.AccessToken)
u, err := user_model.GetUserByID(context.Background(), user.ID)
u, err := user_model.GetUserByID(t.Context(), user.ID)
assert.NoError(t, err)
assert.True(t, u.IsActive)
})
t.Run("expired", func(t *testing.T) {
err := source.refresh(context.Background(), provider, &user_model.ExternalLoginUser{
err := source.refresh(t.Context(), provider, &user_model.ExternalLoginUser{
ExternalID: "external",
UserID: user.ID,
LoginSourceID: user.LoginSource,
@@ -86,13 +85,13 @@ func TestSource(t *testing.T) {
LoginSourceID: e.LoginSourceID,
}
ok, err := user_model.GetExternalLogin(context.Background(), e)
ok, err := user_model.GetExternalLogin(t.Context(), e)
assert.NoError(t, err)
assert.True(t, ok)
assert.Equal(t, "", e.RefreshToken)
assert.Equal(t, "", e.AccessToken)
u, err := user_model.GetUserByID(context.Background(), user.ID)
u, err := user_model.GetUserByID(t.Context(), user.ID)
assert.NoError(t, err)
assert.False(t, u.IsActive)
})

View File

@@ -5,7 +5,6 @@
package gitdiff
import (
"context"
"strconv"
"strings"
"testing"
@@ -629,12 +628,12 @@ func TestDiffLine_GetCommentSide(t *testing.T) {
}
func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) {
gitRepo, err := git.OpenRepository(context.Background(), "../../modules/git/tests/repos/repo5_pulls")
gitRepo, err := git.OpenRepository(t.Context(), "../../modules/git/tests/repos/repo5_pulls")
require.NoError(t, err)
defer gitRepo.Close()
for _, behavior := range []git.TrustedCmdArgs{{"-w"}, {"--ignore-space-at-eol"}, {"-b"}, nil} {
diffs, err := GetDiff(context.Background(), gitRepo,
diffs, err := GetDiff(t.Context(), gitRepo,
&DiffOptions{
AfterCommitID: "d8e0bbb45f200e67d9a784ce55bd90821af45ebd",
BeforeCommitID: "72866af952e98d02a73003501836074b286a78f6",

View File

@@ -4,7 +4,6 @@
package gitdiff
import (
"context"
"strings"
"testing"
@@ -224,7 +223,7 @@ func TestSubmoduleInfo(t *testing.T) {
PreviousRefID: "aaaa",
NewRefID: "bbbb",
}
ctx := context.Background()
ctx := t.Context()
assert.EqualValues(t, "1111", sdi.CommitRefIDLinkHTML(ctx, "1111"))
assert.EqualValues(t, "aaaa...bbbb", sdi.CompareRefIDLinkHTML(ctx))
assert.EqualValues(t, "name", sdi.SubmoduleRepoLinkHTML(ctx))

View File

@@ -85,7 +85,7 @@ func TestComposeIssueCommentMessage(t *testing.T) {
recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}}
msgs, err := composeIssueCommentMessages(&mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: activities_model.ActionCommentIssue,
Content: fmt.Sprintf("test @%s %s#%d body", doer.Name, issue.Repo.FullName(), issue.Index),
Comment: comment,
@@ -131,7 +131,7 @@ func TestComposeIssueMessage(t *testing.T) {
recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}}
msgs, err := composeIssueCommentMessages(&mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: activities_model.ActionCreateIssue,
Content: "test body",
}, "en-US", recipients, false, "issue create")
@@ -178,14 +178,14 @@ func TestTemplateSelection(t *testing.T) {
}
msg := testComposeIssueCommentMessage(t, &mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: activities_model.ActionCreateIssue,
Content: "test body",
}, recipients, false, "TestTemplateSelection")
expect(t, msg, "issue/new/subject", "issue/new/body")
msg = testComposeIssueCommentMessage(t, &mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: activities_model.ActionCommentIssue,
Content: "test body", Comment: comment,
}, recipients, false, "TestTemplateSelection")
@@ -194,14 +194,14 @@ func TestTemplateSelection(t *testing.T) {
pull := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2, Repo: repo, Poster: doer})
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4, Issue: pull})
msg = testComposeIssueCommentMessage(t, &mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: pull, Doer: doer, ActionType: activities_model.ActionCommentPull,
Content: "test body", Comment: comment,
}, recipients, false, "TestTemplateSelection")
expect(t, msg, "pull/comment/subject", "pull/comment/body")
msg = testComposeIssueCommentMessage(t, &mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: activities_model.ActionCloseIssue,
Content: "test body", Comment: comment,
}, recipients, false, "TestTemplateSelection")
@@ -220,7 +220,7 @@ func TestTemplateServices(t *testing.T) {
recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}}
msg := testComposeIssueCommentMessage(t, &mailCommentContext{
Context: context.TODO(),
Context: t.Context(),
Issue: issue, Doer: doer, ActionType: actionType,
Content: "test body", Comment: comment,
}, recipients, fromMention, "TestTemplateServices")
@@ -263,7 +263,7 @@ func testComposeIssueCommentMessage(t *testing.T, ctx *mailCommentContext, recip
func TestGenerateAdditionalHeaders(t *testing.T) {
doer, _, issue, _ := prepareMailerTest(t)
ctx := &mailCommentContext{Context: context.TODO(), Issue: issue, Doer: doer}
ctx := &mailCommentContext{Context: t.Context(), Issue: issue, Doer: doer}
recipient := &user_model.User{Name: "test", Email: "test@gitea.com"}
headers := generateAdditionalHeaders(ctx, "dummy-reason", recipient)

View File

@@ -4,7 +4,6 @@
package markup
import (
"context"
"net/http"
"net/http/httptest"
"testing"
@@ -32,10 +31,10 @@ func TestRenderHelperMention(t *testing.T) {
unittest.AssertCount(t, &user.User{Name: userNoSuch}, 0)
// when using general context, use user's visibility to check
assert.True(t, FormalRenderHelperFuncs().IsUsernameMentionable(context.Background(), userPublic))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(context.Background(), userLimited))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(context.Background(), userPrivate))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(context.Background(), userNoSuch))
assert.True(t, FormalRenderHelperFuncs().IsUsernameMentionable(t.Context(), userPublic))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(t.Context(), userLimited))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(t.Context(), userPrivate))
assert.False(t, FormalRenderHelperFuncs().IsUsernameMentionable(t.Context(), userNoSuch))
// when using web context, use user.IsUserVisibleToViewer to check
req, err := http.NewRequest("GET", "/", nil)

View File

@@ -4,7 +4,6 @@
package migrations
import (
"context"
"net/url"
"os"
"testing"
@@ -30,7 +29,7 @@ func TestCodebaseDownloadRepo(t *testing.T) {
if cloneUser != "" {
u.User = url.UserPassword(cloneUser, clonePassword)
}
ctx := context.Background()
ctx := t.Context()
factory := &CodebaseDownloaderFactory{}
downloader, err := factory.New(ctx, base.MigrateOptions{
CloneAddr: u.String(),

View File

@@ -4,7 +4,6 @@
package migrations
import (
"context"
"net/http"
"os"
"sort"
@@ -28,7 +27,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
if err != nil || resp.StatusCode != http.StatusOK {
t.Skipf("Can't reach https://gitea.com, skipping %s", t.Name())
}
ctx := context.Background()
ctx := t.Context()
downloader, err := NewGiteaDownloader(ctx, "https://gitea.com", "gitea/test_repo", "", "", giteaToken)
require.NoError(t, err, "NewGiteaDownloader error occur")
require.NotNil(t, downloader, "NewGiteaDownloader is nil")

View File

@@ -5,7 +5,6 @@
package migrations
import (
"context"
"fmt"
"os"
"path/filepath"
@@ -40,7 +39,7 @@ func TestGiteaUploadRepo(t *testing.T) {
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
var (
ctx = context.Background()
ctx = t.Context()
downloader = NewGithubDownloaderV3(ctx, "https://github.com", "", "", "", "go-xorm", "builder")
repoName = "builder-" + time.Now().Format("2006-01-02-15-04-05")
uploader = NewGiteaLocalUploader(graceful.GetManager().HammerContext(), user, user.Name, repoName)
@@ -132,7 +131,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
ctx := context.Background()
ctx := t.Context()
repoName := "migrated"
uploader := NewGiteaLocalUploader(ctx, doer, doer.Name, repoName)
// call remapLocalUser
@@ -181,7 +180,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
func TestGiteaUploadRemapExternalUser(t *testing.T) {
unittest.PrepareTestEnv(t)
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
ctx := context.Background()
ctx := t.Context()
repoName := "migrated"
uploader := NewGiteaLocalUploader(ctx, doer, doer.Name, repoName)
uploader.gitServiceType = structs.GiteaService
@@ -302,11 +301,11 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
assert.NoError(t, err)
toRepoName := "migrated"
ctx := context.Background()
ctx := t.Context()
uploader := NewGiteaLocalUploader(ctx, fromRepoOwner, fromRepoOwner.Name, toRepoName)
uploader.gitServiceType = structs.GiteaService
assert.NoError(t, repo_service.Init(context.Background()))
assert.NoError(t, repo_service.Init(t.Context()))
assert.NoError(t, uploader.CreateRepo(ctx, &base.Repository{
Description: "description",
OriginalURL: fromRepo.RepoPath(),

View File

@@ -5,7 +5,6 @@
package migrations
import (
"context"
"os"
"testing"
"time"
@@ -21,7 +20,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
if token == "" {
t.Skip("Skipping GitHub migration test because GITHUB_READ_TOKEN is empty")
}
ctx := context.Background()
ctx := t.Context()
downloader := NewGithubDownloaderV3(ctx, "https://github.com", "", "", token, "go-gitea", "test_repo")
err := downloader.RefreshRate(ctx)
assert.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package migrations
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
@@ -31,7 +30,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
if err != nil || resp.StatusCode != http.StatusOK {
t.Skipf("Can't access test repo, skipping %s", t.Name())
}
ctx := context.Background()
ctx := t.Context()
downloader, err := NewGitlabDownloader(ctx, "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken)
if err != nil {
t.Fatalf("NewGitlabDownloader is nil: %v", err)
@@ -423,7 +422,7 @@ func TestGitlabGetReviews(t *testing.T) {
defer gitlabClientMockTeardown(server)
repoID := 1324
ctx := context.Background()
ctx := t.Context()
downloader := &GitlabDownloader{
client: client,
repoID: repoID,

View File

@@ -4,7 +4,6 @@
package migrations
import (
"context"
"net/http"
"os"
"testing"
@@ -28,7 +27,7 @@ func TestGogsDownloadRepo(t *testing.T) {
t.Skipf("visit test repo failed, ignored")
return
}
ctx := context.Background()
ctx := t.Context()
downloader := NewGogsDownloader(ctx, "https://try.gogs.io", "", "", gogsPersonalAccessToken, "lunnytest", "TESTREPO")
repo, err := downloader.GetRepoInfo(ctx)
assert.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package migrations
import (
"context"
"net/http"
"net/url"
"testing"
@@ -22,7 +21,7 @@ func TestOneDevDownloadRepo(t *testing.T) {
}
u, _ := url.Parse("https://code.onedev.io")
ctx := context.Background()
ctx := t.Context()
downloader := NewOneDevDownloader(ctx, u, "", "", "go-gitea-test_repo")
if err != nil {
t.Fatalf("NewOneDevDownloader is nil: %v", err)

View File

@@ -5,7 +5,6 @@
package pull
import (
"context"
"strconv"
"testing"
"time"
@@ -33,7 +32,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
cfg, err := setting.GetQueueSettings(setting.CfgProvider, "pr_patch_checker")
assert.NoError(t, err)
prPatchCheckerQueue, err = queue.NewWorkerPoolQueueWithContext(context.Background(), "pr_patch_checker", cfg, testHandler, true)
prPatchCheckerQueue, err = queue.NewWorkerPoolQueueWithContext(t.Context(), "pr_patch_checker", cfg, testHandler, true)
assert.NoError(t, err)
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})

View File

@@ -21,7 +21,7 @@ func BenchmarkGetCommitGraph(b *testing.B) {
}
defer currentRepo.Close()
for i := 0; i < b.N; i++ {
for b.Loop() {
graph, err := GetCommitGraph(currentRepo, 1, 0, false, nil, nil)
if err != nil {
b.Error("Could get commit graph")
@@ -38,7 +38,7 @@ func BenchmarkParseCommitString(b *testing.B) {
parser := &Parser{}
parser.Reset()
for i := 0; i < b.N; i++ {
for b.Loop() {
parser.Reset()
graph := NewGraph()
if err := parser.AddLineToGraph(graph, 0, []byte(testString)); err != nil {
@@ -55,7 +55,7 @@ func BenchmarkParseGlyphs(b *testing.B) {
parser.Reset()
tgBytes := []byte(testglyphs)
var tg []byte
for i := 0; i < b.N; i++ {
for b.Loop() {
parser.Reset()
tg = tgBytes
idx := bytes.Index(tg, []byte("\n"))
@@ -267,446 +267,446 @@ func TestCommitStringParsing(t *testing.T) {
}
}
var testglyphs = `*
*
*
*
*
*
*
*
|\
* |
* |
* |
* |
* |
| *
* |
| *
| |\
* | |
| | *
| | |\
* | | \
|\ \ \ \
| * | | |
| |\| | |
* | | | |
|/ / / /
| | | *
| * | |
| * | |
| * | |
* | | |
* | | |
* | | |
* | | |
* | | |
|\ \ \ \
| | * | |
| | |\| |
| | | * |
| | | | *
* | | | |
* | | | |
* | | | |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | |/ / /
| |/| | |
| | | | *
| * | | |
|/| | | |
| * | | |
|/| | | |
| | |/ /
| |/| |
| * | |
| * | |
| |\ \ \
| | * | |
| |/| | |
| | | |/
| | |/|
| * | |
| * | |
| * | |
| | * |
| | |\ \
| | | * |
| | |/| |
| | | * |
| | | |\ \
| | | | * |
| | | |/| |
| | * | | |
| | * | | |
| | |\ \ \ \
| | | * | | |
| | |/| | | |
| | | | | * |
| | | | |/ /
* | | | / /
|/ / / / /
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| * | | | |
| * | | | |
| |\ \ \ \ \
| | | * \ \ \
| | | |\ \ \ \
| | | | * | | |
| | | |/| | | |
| | | | | |/ /
| | | | |/| |
* | | | | | |
* | | | | | |
* | | | | | |
| | | | * | |
* | | | | | |
| | * | | | |
| |/| | | | |
* | | | | | |
| |/ / / / /
|/| | | | |
| | | | * |
| | | |/ /
| | |/| |
| * | | |
| | | | *
| | * | |
| | |\ \ \
| | | * | |
| | |/| | |
| | | |/ /
| | | * |
| | * | |
| | |\ \ \
| | | * | |
| | |/| | |
| | | |/ /
| | | * |
* | | | |
|\ \ \ \ \
| * \ \ \ \
| |\ \ \ \ \
| | | |/ / /
| | |/| | |
| | | | * |
| | | | * |
* | | | | |
* | | | | |
|/ / / / /
| | | * |
* | | | |
* | | | |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | * | | |
| | |\ \ \ \
| | | * | | |
| | |/| | | |
| |/| | |/ /
| | | |/| |
| | | | | *
| |_|_|_|/
|/| | | |
| | * | |
| |/ / /
* | | |
* | | |
| | * |
* | | |
* | | |
| * | |
| | * |
| * | |
* | | |
|\ \ \ \
| * | | |
|/| | | |
| |/ / /
| * | |
| |\ \ \
| | * | |
| |/| | |
| | |/ /
| | * |
| | |\ \
| | | * |
| | |/| |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | * | | |
| | * | | |
| | * | | |
| |/ / / /
| * | | |
| |\ \ \ \
| | * | | |
| |/| | | |
* | | | | |
* | | | | |
* | | | | |
* | | | | |
* | | | | |
| | | | * |
* | | | | |
|\ \ \ \ \ \
| * | | | | |
|/| | | | | |
| | | | | * |
| | | | |/ /
* | | | | |
|\ \ \ \ \ \
* | | | | | |
* | | | | | |
| | | | * | |
* | | | | | |
* | | | | | |
|\ \ \ \ \ \ \
| | |_|_|/ / /
| |/| | | | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | |/ / /
| | | * | |
| | | * | |
| | | * | |
| | |/| | |
| | | * | |
| | |/| | |
| | | |/ /
| | * | |
| |/| | |
| | | * |
| | |/ /
| | * |
| * | |
| |\ \ \
| * | | |
| | * | |
| |/| | |
| | |/ /
| | * |
| | |\ \
| | * | |
* | | | |
|\| | | |
| * | | |
| * | | |
| * | | |
| | * | |
| * | | |
| |\| | |
| * | | |
| | * | |
| | * | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
* | | | |
|\| | | |
| | * | |
| * | | |
| |\| | |
| | * | |
| | * | |
| | * | |
| | | * |
* | | | |
|\| | | |
| | * | |
| | |/ /
| * | |
| * | |
| |\| |
* | | |
|\| | |
| | * |
| | * |
| | * |
| * | |
| | * |
| * | |
| | * |
| | * |
| | * |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| |\| |
| | * |
| | |\ \
* | | | |
|\| | | |
| * | | |
| |\| | |
| | * | |
| | | * |
| | |/ /
* | | |
* | | |
|\| | |
| * | |
| |\| |
| | * |
| | * |
| | * |
| | | *
* | | |
|\| | |
| * | |
| * | |
| | | *
| | | |\
* | | | |
| |_|_|/
|/| | |
| * | |
| |\| |
| | * |
| | * |
| | * |
| | * |
| | * |
| * | |
* | | |
|\| | |
| * | |
|/| | |
| |/ /
| * |
| |\ \
| * | |
| * | |
* | | |
|\| | |
| | * |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| * | |
| | * |
| | |\ \
| | |/ /
| |/| |
| * | |
* | | |
|\| | |
| * | |
* | | |
|\| | |
| * | |
| |\ \ \
| * | | |
| * | | |
| | | * |
| * | | |
| * | | |
| | |/ /
| |/| |
| | * |
* | | |
|\| | |
| * | |
| * | |
| * | |
| * | |
| * | |
| |\ \ \
* | | | |
|\| | | |
| * | | |
| * | | |
* | | | |
* | | | |
|\| | | |
| | | | *
| | | | |\
| |_|_|_|/
|/| | | |
| * | | |
* | | | |
* | | | |
|\| | | |
| * | | |
| |\ \ \ \
| | | |/ /
| | |/| |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
| | | * |
| | |/ /
| |/| |
* | | |
|\| | |
| * | |
| * | |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| * | |
* | | |
| * | |
| * | |
| * | |
* | | |
* | | |
* | | |
|\| | |
| * | |
* | | |
* | | |
* | | |
* | | |
| | | *
* | | |
|\| | |
| * | |
| * | |
| * | |
var testglyphs = `*
*
*
*
*
*
*
*
|\
* |
* |
* |
* |
* |
| *
* |
| *
| |\
* | |
| | *
| | |\
* | | \
|\ \ \ \
| * | | |
| |\| | |
* | | | |
|/ / / /
| | | *
| * | |
| * | |
| * | |
* | | |
* | | |
* | | |
* | | |
* | | |
|\ \ \ \
| | * | |
| | |\| |
| | | * |
| | | | *
* | | | |
* | | | |
* | | | |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | |/ / /
| |/| | |
| | | | *
| * | | |
|/| | | |
| * | | |
|/| | | |
| | |/ /
| |/| |
| * | |
| * | |
| |\ \ \
| | * | |
| |/| | |
| | | |/
| | |/|
| * | |
| * | |
| * | |
| | * |
| | |\ \
| | | * |
| | |/| |
| | | * |
| | | |\ \
| | | | * |
| | | |/| |
| | * | | |
| | * | | |
| | |\ \ \ \
| | | * | | |
| | |/| | | |
| | | | | * |
| | | | |/ /
* | | | / /
|/ / / / /
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| * | | | |
| * | | | |
| |\ \ \ \ \
| | | * \ \ \
| | | |\ \ \ \
| | | | * | | |
| | | |/| | | |
| | | | | |/ /
| | | | |/| |
* | | | | | |
* | | | | | |
* | | | | | |
| | | | * | |
* | | | | | |
| | * | | | |
| |/| | | | |
* | | | | | |
| |/ / / / /
|/| | | | |
| | | | * |
| | | |/ /
| | |/| |
| * | | |
| | | | *
| | * | |
| | |\ \ \
| | | * | |
| | |/| | |
| | | |/ /
| | | * |
| | * | |
| | |\ \ \
| | | * | |
| | |/| | |
| | | |/ /
| | | * |
* | | | |
|\ \ \ \ \
| * \ \ \ \
| |\ \ \ \ \
| | | |/ / /
| | |/| | |
| | | | * |
| | | | * |
* | | | | |
* | | | | |
|/ / / / /
| | | * |
* | | | |
* | | | |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | * | | |
| | |\ \ \ \
| | | * | | |
| | |/| | | |
| |/| | |/ /
| | | |/| |
| | | | | *
| |_|_|_|/
|/| | | |
| | * | |
| |/ / /
* | | |
* | | |
| | * |
* | | |
* | | |
| * | |
| | * |
| * | |
* | | |
|\ \ \ \
| * | | |
|/| | | |
| |/ / /
| * | |
| |\ \ \
| | * | |
| |/| | |
| | |/ /
| | * |
| | |\ \
| | | * |
| | |/| |
* | | | |
* | | | |
|\ \ \ \ \
| * | | | |
|/| | | | |
| | * | | |
| | * | | |
| | * | | |
| |/ / / /
| * | | |
| |\ \ \ \
| | * | | |
| |/| | | |
* | | | | |
* | | | | |
* | | | | |
* | | | | |
* | | | | |
| | | | * |
* | | | | |
|\ \ \ \ \ \
| * | | | | |
|/| | | | | |
| | | | | * |
| | | | |/ /
* | | | | |
|\ \ \ \ \ \
* | | | | | |
* | | | | | |
| | | | * | |
* | | | | | |
* | | | | | |
|\ \ \ \ \ \ \
| | |_|_|/ / /
| |/| | | | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | | * | |
| | | |/ / /
| | | * | |
| | | * | |
| | | * | |
| | |/| | |
| | | * | |
| | |/| | |
| | | |/ /
| | * | |
| |/| | |
| | | * |
| | |/ /
| | * |
| * | |
| |\ \ \
| * | | |
| | * | |
| |/| | |
| | |/ /
| | * |
| | |\ \
| | * | |
* | | | |
|\| | | |
| * | | |
| * | | |
| * | | |
| | * | |
| * | | |
| |\| | |
| * | | |
| | * | |
| | * | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
* | | | |
|\| | | |
| | * | |
| * | | |
| |\| | |
| | * | |
| | * | |
| | * | |
| | | * |
* | | | |
|\| | | |
| | * | |
| | |/ /
| * | |
| * | |
| |\| |
* | | |
|\| | |
| | * |
| | * |
| | * |
| * | |
| | * |
| * | |
| | * |
| | * |
| | * |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| |\| |
| | * |
| | |\ \
* | | | |
|\| | | |
| * | | |
| |\| | |
| | * | |
| | | * |
| | |/ /
* | | |
* | | |
|\| | |
| * | |
| |\| |
| | * |
| | * |
| | * |
| | | *
* | | |
|\| | |
| * | |
| * | |
| | | *
| | | |\
* | | | |
| |_|_|/
|/| | |
| * | |
| |\| |
| | * |
| | * |
| | * |
| | * |
| | * |
| * | |
* | | |
|\| | |
| * | |
|/| | |
| |/ /
| * |
| |\ \
| * | |
| * | |
* | | |
|\| | |
| | * |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| * | |
| | * |
| | |\ \
| | |/ /
| |/| |
| * | |
* | | |
|\| | |
| * | |
* | | |
|\| | |
| * | |
| |\ \ \
| * | | |
| * | | |
| | | * |
| * | | |
| * | | |
| | |/ /
| |/| |
| | * |
* | | |
|\| | |
| * | |
| * | |
| * | |
| * | |
| * | |
| |\ \ \
* | | | |
|\| | | |
| * | | |
| * | | |
* | | | |
* | | | |
|\| | | |
| | | | *
| | | | |\
| |_|_|_|/
|/| | | |
| * | | |
* | | | |
* | | | |
|\| | | |
| * | | |
| |\ \ \ \
| | | |/ /
| | |/| |
| * | | |
| * | | |
| * | | |
| * | | |
| | * | |
| | | * |
| | |/ /
| |/| |
* | | |
|\| | |
| * | |
| * | |
| * | |
| * | |
| * | |
* | | |
|\| | |
| * | |
| * | |
* | | |
| * | |
| * | |
| * | |
* | | |
* | | |
* | | |
|\| | |
| * | |
* | | |
* | | |
* | | |
* | | |
| | | *
* | | |
|\| | |
| * | |
| * | |
| * | |
`

View File

@@ -5,7 +5,6 @@ package repository_test
import (
"bytes"
"context"
"testing"
"time"
@@ -36,7 +35,7 @@ func TestGarbageCollectLFSMetaObjects(t *testing.T) {
lfsOid := storeObjectInRepo(t, repo.ID, &lfsContent)
// gc
err = repo_service.GarbageCollectLFSMetaObjects(context.Background(), repo_service.GarbageCollectLFSMetaObjectsOptions{
err = repo_service.GarbageCollectLFSMetaObjects(t.Context(), repo_service.GarbageCollectLFSMetaObjectsOptions{
AutoFix: true,
OlderThan: time.Now().Add(7 * 24 * time.Hour).Add(5 * 24 * time.Hour),
UpdatedLessRecentlyThan: time.Now().Add(7 * 24 * time.Hour).Add(3 * 24 * time.Hour),

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"io"
"net/http"
"net/http/httptest"
@@ -118,7 +117,7 @@ func TestWebhookDeliverAuthorizationHeader(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, hookTask)
assert.NoError(t, Deliver(context.Background(), hookTask))
assert.NoError(t, Deliver(t.Context(), hookTask))
select {
case <-done:
case <-time.After(5 * time.Second):
@@ -185,7 +184,7 @@ func TestWebhookDeliverHookTask(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, hookTask)
assert.NoError(t, Deliver(context.Background(), hookTask))
assert.NoError(t, Deliver(t.Context(), hookTask))
select {
case <-done:
case <-time.After(5 * time.Second):
@@ -211,7 +210,7 @@ func TestWebhookDeliverHookTask(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, hookTask)
assert.NoError(t, Deliver(context.Background(), hookTask))
assert.NoError(t, Deliver(t.Context(), hookTask))
select {
case <-done:
case <-time.After(5 * time.Second):
@@ -280,7 +279,7 @@ func TestWebhookDeliverSpecificTypes(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, hookTask)
assert.NoError(t, Deliver(context.Background(), hookTask))
assert.NoError(t, Deliver(t.Context(), hookTask))
select {
case gotBody := <-cases[typ].gotBody:

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"net/url"
"testing"
@@ -236,7 +235,7 @@ func TestDingTalkJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newDingtalkRequest(context.Background(), hook, task)
req, reqBody, err := newDingtalkRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -303,7 +302,7 @@ func TestDiscordJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newDiscordRequest(context.Background(), hook, task)
req, reqBody, err := newDiscordRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -177,7 +176,7 @@ func TestFeishuJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newFeishuRequest(context.Background(), hook, task)
req, reqBody, err := newFeishuRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -211,7 +210,7 @@ func TestMatrixJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newMatrixRequest(context.Background(), hook, task)
req, reqBody, err := newMatrixRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -439,7 +438,7 @@ func TestMSTeamsJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newMSTeamsRequest(context.Background(), hook, task)
req, reqBody, err := newMSTeamsRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -164,7 +163,7 @@ func TestPackagistJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newPackagistRequest(context.Background(), hook, task)
req, reqBody, err := newPackagistRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)
@@ -199,7 +198,7 @@ func TestPackagistEmptyPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newPackagistRequest(context.Background(), hook, task)
req, reqBody, err := newPackagistRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -178,7 +177,7 @@ func TestSlackJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newSlackRequest(context.Background(), hook, task)
req, reqBody, err := newSlackRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)

View File

@@ -4,7 +4,6 @@
package webhook
import (
"context"
"testing"
webhook_model "code.gitea.io/gitea/models/webhook"
@@ -195,7 +194,7 @@ func TestTelegramJSONPayload(t *testing.T) {
PayloadVersion: 2,
}
req, reqBody, err := newTelegramRequest(context.Background(), hook, task)
req, reqBody, err := newTelegramRequest(t.Context(), hook, task)
require.NotNil(t, req)
require.NotNil(t, reqBody)
require.NoError(t, err)