mirror of
https://github.com/go-gitea/gitea
synced 2025-07-09 20:17:21 +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:
@ -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(),
|
||||
|
Reference in New Issue
Block a user