Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v1.64.6 (forgejo) (#7118)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
		
					parent
					
						
							
								bb0e26a7b4
							
						
					
				
			
			
				commit
				
					
						6b436955fc
					
				
			
		
					 97 changed files with 258 additions and 345 deletions
				
			
		| 
						 | 
				
			
			@ -19,12 +19,12 @@ linters:
 | 
			
		|||
    - revive
 | 
			
		||||
    - staticcheck
 | 
			
		||||
    - stylecheck
 | 
			
		||||
    - tenv
 | 
			
		||||
    - testifylint
 | 
			
		||||
    - typecheck
 | 
			
		||||
    - unconvert
 | 
			
		||||
    - unused
 | 
			
		||||
    - unparam
 | 
			
		||||
    - usetesting
 | 
			
		||||
    - wastedassign
 | 
			
		||||
 | 
			
		||||
run:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -39,7 +39,7 @@ XGO_VERSION := go-1.21.x
 | 
			
		|||
AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go
 | 
			
		||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.0 # renovate: datasource=go
 | 
			
		||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0 # renovate: datasource=go
 | 
			
		||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 # renovate: datasource=go
 | 
			
		||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.6 # renovate: datasource=go
 | 
			
		||||
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 # renovate: datasource=go
 | 
			
		||||
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0 # renovate: datasource=go
 | 
			
		||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 # renovate: datasource=go
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,6 @@ package cmd
 | 
			
		|||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +41,7 @@ func captureOutput(t *testing.T, stdFD *os.File) (finish func() (output string))
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestPktLine(t *testing.T) {
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	t.Run("Read", func(t *testing.T) {
 | 
			
		||||
		s := strings.NewReader("0000")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package cmd
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +30,7 @@ func createLocalStorage(t *testing.T) (storage.ObjectStorage, string) {
 | 
			
		|||
	p := t.TempDir()
 | 
			
		||||
 | 
			
		||||
	storage, err := storage.NewLocalStorage(
 | 
			
		||||
		context.Background(),
 | 
			
		||||
		t.Context(),
 | 
			
		||||
		&setting.Storage{
 | 
			
		||||
			Path: p,
 | 
			
		||||
		})
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +71,7 @@ func TestMigratePackages(t *testing.T) {
 | 
			
		|||
	assert.NotNil(t, v)
 | 
			
		||||
	assert.NotNil(t, f)
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	dstStorage, p := createLocalStorage(t)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package issues_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"sync"
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +308,7 @@ func TestIssue_ResolveMentions(t *testing.T) {
 | 
			
		|||
func TestResourceIndex(t *testing.T) {
 | 
			
		||||
	require.NoError(t, unittest.PrepareTestDatabase())
 | 
			
		||||
 | 
			
		||||
	beforeCount, err := issues_model.CountIssues(context.Background(), &issues_model.IssuesOptions{})
 | 
			
		||||
	beforeCount, err := issues_model.CountIssues(t.Context(), &issues_model.IssuesOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	var wg sync.WaitGroup
 | 
			
		||||
| 
						 | 
				
			
			@ -326,7 +325,7 @@ func TestResourceIndex(t *testing.T) {
 | 
			
		|||
		t.Parallel()
 | 
			
		||||
 | 
			
		||||
		wg.Wait()
 | 
			
		||||
		afterCount, err := issues_model.CountIssues(context.Background(), &issues_model.IssuesOptions{})
 | 
			
		||||
		afterCount, err := issues_model.CountIssues(t.Context(), &issues_model.IssuesOptions{})
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.EqualValues(t, 100, afterCount-beforeCount)
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +353,7 @@ func TestCorrectIssueStats(t *testing.T) {
 | 
			
		|||
	wg.Wait()
 | 
			
		||||
 | 
			
		||||
	// Now we will get all issueID's that match the "Bugs are nasty" query.
 | 
			
		||||
	issues, err := issues_model.Issues(context.TODO(), &issues_model.IssuesOptions{
 | 
			
		||||
	issues, err := issues_model.Issues(t.Context(), &issues_model.IssuesOptions{
 | 
			
		||||
		Paginator: &db.ListOptions{
 | 
			
		||||
			PageSize: issueAmount,
 | 
			
		||||
		},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package user
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +36,7 @@ func TestUserAvatarGenerate(t *testing.T) {
 | 
			
		|||
	require.NoError(t, unittest.PrepareTestDatabase())
 | 
			
		||||
	var err error
 | 
			
		||||
	tmpDir := t.TempDir()
 | 
			
		||||
	storage.Avatars, err = storage.NewLocalStorage(context.Background(), &setting.Storage{Path: tmpDir})
 | 
			
		||||
	storage.Avatars, err = storage.NewLocalStorage(t.Context(), &setting.Storage{Path: tmpDir})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	u := unittest.AssertExistsAndLoadBean(t, &User{ID: 2})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package user_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"fmt"
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +345,7 @@ func TestCreateUserCustomTimestamps(t *testing.T) {
 | 
			
		|||
	err := user_model.CreateUser(db.DefaultContext, user)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	fetched, err := user_model.GetUserByID(context.Background(), user.ID)
 | 
			
		||||
	fetched, err := user_model.GetUserByID(t.Context(), user.ID)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, creationTimestamp, fetched.CreatedUnix)
 | 
			
		||||
	assert.Equal(t, creationTimestamp, fetched.UpdatedUnix)
 | 
			
		||||
| 
						 | 
				
			
			@ -373,7 +372,7 @@ func TestCreateUserWithoutCustomTimestamps(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	timestampEnd := time.Now().Unix()
 | 
			
		||||
 | 
			
		||||
	fetched, err := user_model.GetUserByID(context.Background(), user.ID)
 | 
			
		||||
	fetched, err := user_model.GetUserByID(t.Context(), user.ID)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	assert.LessOrEqual(t, timestampStart, fetched.CreatedUnix)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +261,7 @@ func TestCleanupHookTaskTable_PerWebhook_DeletesDelivered(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), PerWebhook, 168*time.Hour, 0))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), PerWebhook, 168*time.Hour, 0))
 | 
			
		||||
	unittest.AssertNotExistsBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -278,7 +277,7 @@ func TestCleanupHookTaskTable_PerWebhook_LeavesUndelivered(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), PerWebhook, 168*time.Hour, 0))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), PerWebhook, 168*time.Hour, 0))
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -295,7 +294,7 @@ func TestCleanupHookTaskTable_PerWebhook_LeavesMostRecentTask(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), PerWebhook, 168*time.Hour, 1))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), PerWebhook, 168*time.Hour, 1))
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +311,7 @@ func TestCleanupHookTaskTable_OlderThan_DeletesDelivered(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	unittest.AssertNotExistsBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -328,7 +327,7 @@ func TestCleanupHookTaskTable_OlderThan_LeavesUndelivered(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -345,6 +344,6 @@ func TestCleanupHookTaskTable_OlderThan_LeavesTaskEarlierThanAgeToDelete(t *test
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(context.Background(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	require.NoError(t, CleanupHookTaskTable(t.Context(), OlderThan, 168*time.Hour, 0))
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, hookTask)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								modules/cache/context_test.go
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								modules/cache/context_test.go
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package cache
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +12,7 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestWithCacheContext(t *testing.T) {
 | 
			
		||||
	ctx := WithCacheContext(context.Background())
 | 
			
		||||
	ctx := WithCacheContext(t.Context())
 | 
			
		||||
 | 
			
		||||
	v := GetContextData(ctx, "empty_field", "my_config1")
 | 
			
		||||
	assert.Nil(t, v)
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +52,7 @@ func TestWithCacheContext(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestWithNoCacheContext(t *testing.T) {
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	const field = "system_setting"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@ import (
 | 
			
		|||
func TestReadingBlameOutputSha256(t *testing.T) {
 | 
			
		||||
	skipIfSHA256NotSupported(t)
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	t.Run("Without .git-blame-ignore-revs", func(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestReadingBlameOutput(t *testing.T) {
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	t.Run("Without .git-blame-ignore-revs", func(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
| 
						 | 
				
			
			@ -12,13 +11,13 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestRunWithContextStd(t *testing.T) {
 | 
			
		||||
	cmd := NewCommand(context.Background(), "--version")
 | 
			
		||||
	cmd := NewCommand(t.Context(), "--version")
 | 
			
		||||
	stdout, stderr, err := cmd.RunStdString(&RunOpts{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Empty(t, stderr)
 | 
			
		||||
	assert.Contains(t, stdout, "git version")
 | 
			
		||||
 | 
			
		||||
	cmd = NewCommand(context.Background(), "--no-such-arg")
 | 
			
		||||
	cmd = NewCommand(t.Context(), "--no-such-arg")
 | 
			
		||||
	stdout, stderr, err = cmd.RunStdString(&RunOpts{})
 | 
			
		||||
	if assert.Error(t, err) {
 | 
			
		||||
		assert.Equal(t, stderr, err.Stderr())
 | 
			
		||||
| 
						 | 
				
			
			@ -27,16 +26,16 @@ func TestRunWithContextStd(t *testing.T) {
 | 
			
		|||
		assert.Empty(t, stdout)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd = NewCommand(context.Background())
 | 
			
		||||
	cmd = NewCommand(t.Context())
 | 
			
		||||
	cmd.AddDynamicArguments("-test")
 | 
			
		||||
	require.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
 | 
			
		||||
 | 
			
		||||
	cmd = NewCommand(context.Background())
 | 
			
		||||
	cmd = NewCommand(t.Context())
 | 
			
		||||
	cmd.AddDynamicArguments("--test")
 | 
			
		||||
	require.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
 | 
			
		||||
 | 
			
		||||
	subCmd := "version"
 | 
			
		||||
	cmd = NewCommand(context.Background()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
 | 
			
		||||
	cmd = NewCommand(t.Context()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
 | 
			
		||||
	stdout, stderr, err = cmd.RunStdString(&RunOpts{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Empty(t, stderr)
 | 
			
		||||
| 
						 | 
				
			
			@ -55,15 +54,15 @@ func TestGitArgument(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestCommandString(t *testing.T) {
 | 
			
		||||
	cmd := NewCommandContextNoGlobals(context.Background(), "a", "-m msg", "it's a test", `say "hello"`)
 | 
			
		||||
	cmd := NewCommandContextNoGlobals(t.Context(), "a", "-m msg", "it's a test", `say "hello"`)
 | 
			
		||||
	assert.EqualValues(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
 | 
			
		||||
 | 
			
		||||
	cmd = NewCommandContextNoGlobals(context.Background(), "url: https://a:b@c/")
 | 
			
		||||
	cmd = NewCommandContextNoGlobals(t.Context(), "url: https://a:b@c/")
 | 
			
		||||
	assert.EqualValues(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestGrepOnlyFunction(t *testing.T) {
 | 
			
		||||
	cmd := NewCommand(context.Background(), "anything-but-grep")
 | 
			
		||||
	cmd := NewCommand(t.Context(), "anything-but-grep")
 | 
			
		||||
	assert.Panics(t, func() {
 | 
			
		||||
		cmd.AddGitGrepExpression("whatever")
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +83,7 @@ func testGetCommitsInfo(t *testing.T, repo1 *Repository) {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		// FIXME: Context.TODO() - if graceful has started we should use its Shutdown context otherwise use install signals in TestMain.
 | 
			
		||||
		commitsInfo, treeCommit, err := entries.GetCommitsInfo(context.TODO(), commit, testCase.Path)
 | 
			
		||||
		commitsInfo, treeCommit, err := entries.GetCommitsInfo(t.Context(), commit, testCase.Path)
 | 
			
		||||
		require.NoError(t, err, "Unable to get commit information for entries of subtree: %s in commit: %s from testcase due to error: %v", testCase.Path, testCase.CommitID, err)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.FailNow()
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +160,7 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) {
 | 
			
		|||
		b.ResetTimer()
 | 
			
		||||
		b.Run(benchmark.name, func(b *testing.B) {
 | 
			
		||||
			for i := 0; i < b.N; i++ {
 | 
			
		||||
				_, _, err := entries.GetCommitsInfo(context.Background(), commit, "")
 | 
			
		||||
				_, _, err := entries.GetCommitsInfo(b.Context(), commit, "")
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					b.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package git
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +19,7 @@ func TestGrepSearch(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	defer repo.Close()
 | 
			
		||||
 | 
			
		||||
	res, err := GrepSearch(context.Background(), repo, "public", GrepOptions{})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), repo, "public", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []*GrepResult{
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +42,7 @@ func TestGrepSearch(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}, res)
 | 
			
		||||
 | 
			
		||||
	res, err = GrepSearch(context.Background(), repo, "void", GrepOptions{MaxResultLimit: 1, ContextLineNumber: 2})
 | 
			
		||||
	res, err = GrepSearch(t.Context(), repo, "void", GrepOptions{MaxResultLimit: 1, ContextLineNumber: 2})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []*GrepResult{
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +59,7 @@ func TestGrepSearch(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}, res)
 | 
			
		||||
 | 
			
		||||
	res, err = GrepSearch(context.Background(), repo, "world", GrepOptions{MatchesPerFile: 1})
 | 
			
		||||
	res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{MatchesPerFile: 1})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []*GrepResult{
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +88,7 @@ func TestGrepSearch(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}, res)
 | 
			
		||||
 | 
			
		||||
	res, err = GrepSearch(context.Background(), repo, "world", GrepOptions{
 | 
			
		||||
	res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{
 | 
			
		||||
		MatchesPerFile: 1,
 | 
			
		||||
		Filename:       "java-hello/",
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			@ -103,11 +102,11 @@ func TestGrepSearch(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}, res)
 | 
			
		||||
 | 
			
		||||
	res, err = GrepSearch(context.Background(), repo, "no-such-content", GrepOptions{})
 | 
			
		||||
	res, err = GrepSearch(t.Context(), repo, "no-such-content", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Empty(t, res)
 | 
			
		||||
 | 
			
		||||
	res, err = GrepSearch(context.Background(), &Repository{Path: "no-such-git-repo"}, "no-such-content", GrepOptions{})
 | 
			
		||||
	res, err = GrepSearch(t.Context(), &Repository{Path: "no-such-git-repo"}, "no-such-content", GrepOptions{})
 | 
			
		||||
	require.Error(t, err)
 | 
			
		||||
	assert.Empty(t, res)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +130,7 @@ func TestGrepDashesAreFine(t *testing.T) {
 | 
			
		|||
	err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Dashes are cool sometimes"})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	res, err := GrepSearch(context.Background(), gitRepo, "--", GrepOptions{})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), gitRepo, "--", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, res, 1)
 | 
			
		||||
	assert.Equal(t, "with-dashes", res[0].Filename)
 | 
			
		||||
| 
						 | 
				
			
			@ -156,7 +155,7 @@ func TestGrepNoBinary(t *testing.T) {
 | 
			
		|||
	err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Binary and text files"})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	res, err := GrepSearch(context.Background(), gitRepo, "BINARY", GrepOptions{})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), gitRepo, "BINARY", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, res, 1)
 | 
			
		||||
	assert.Equal(t, "TEXT", res[0].Filename)
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +179,7 @@ func TestGrepLongFiles(t *testing.T) {
 | 
			
		|||
	err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Long file"})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	res, err := GrepSearch(context.Background(), gitRepo, "a", GrepOptions{})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), gitRepo, "a", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, res, 1)
 | 
			
		||||
	assert.Len(t, res[0].LineCodes[0], 65*1024)
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +209,7 @@ func TestGrepRefs(t *testing.T) {
 | 
			
		|||
	err = CommitChanges(tmpDir, CommitChangesOptions{Message: "add BCD"})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	res, err := GrepSearch(context.Background(), gitRepo, "a", GrepOptions{RefName: "v1"})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), gitRepo, "a", GrepOptions{RefName: "v1"})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, res, 1)
 | 
			
		||||
	assert.Equal(t, "A", res[0].LineCodes[0])
 | 
			
		||||
| 
						 | 
				
			
			@ -236,12 +235,12 @@ func TestGrepCanHazRegexOnDemand(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	// should find nothing by default...
 | 
			
		||||
	res, err := GrepSearch(context.Background(), gitRepo, "\\bmatch\\b", GrepOptions{})
 | 
			
		||||
	res, err := GrepSearch(t.Context(), gitRepo, "\\bmatch\\b", GrepOptions{})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Empty(t, res)
 | 
			
		||||
 | 
			
		||||
	// ... unless configured explicitly
 | 
			
		||||
	res, err = GrepSearch(context.Background(), gitRepo, "\\bmatch\\b", GrepOptions{Mode: RegExpGrepMode})
 | 
			
		||||
	res, err = GrepSearch(t.Context(), gitRepo, "\\bmatch\\b", GrepOptions{Mode: RegExpGrepMode})
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, res, 1)
 | 
			
		||||
	assert.Equal(t, "matching", res[0].Filename)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,8 +4,6 @@
 | 
			
		|||
package git_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +30,7 @@ func TestGetNotes(t *testing.T) {
 | 
			
		|||
	defer bareRepo1.Close()
 | 
			
		||||
 | 
			
		||||
	note := git.Note{}
 | 
			
		||||
	err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []byte("Note contents\n"), note.Message)
 | 
			
		||||
	assert.Equal(t, "Vladimir Panteleev", note.Commit.Author.Name)
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +43,10 @@ func TestGetNestedNotes(t *testing.T) {
 | 
			
		|||
	defer repo.Close()
 | 
			
		||||
 | 
			
		||||
	note := git.Note{}
 | 
			
		||||
	err = git.GetNote(context.Background(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", ¬e)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []byte("Note 2"), note.Message)
 | 
			
		||||
	err = git.GetNote(context.Background(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", ¬e)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []byte("Note 1"), note.Message)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +58,7 @@ func TestGetNonExistentNotes(t *testing.T) {
 | 
			
		|||
	defer bareRepo1.Close()
 | 
			
		||||
 | 
			
		||||
	note := git.Note{}
 | 
			
		||||
	err = git.GetNote(context.Background(), bareRepo1, "non_existent_sha", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), bareRepo1, "non_existent_sha", ¬e)
 | 
			
		||||
	require.Error(t, err)
 | 
			
		||||
	assert.IsType(t, git.ErrNotExist{}, err)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -68,19 +66,17 @@ func TestGetNonExistentNotes(t *testing.T) {
 | 
			
		|||
func TestSetNote(t *testing.T) {
 | 
			
		||||
	bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
 | 
			
		||||
 | 
			
		||||
	tempDir, err := os.MkdirTemp("", "")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	defer os.RemoveAll(tempDir)
 | 
			
		||||
	tempDir := t.TempDir()
 | 
			
		||||
	require.NoError(t, unittest.CopyDir(bareRepo1Path, filepath.Join(tempDir, "repo1")))
 | 
			
		||||
 | 
			
		||||
	bareRepo1, err := openRepositoryWithDefaultContext(filepath.Join(tempDir, "repo1"))
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	defer bareRepo1.Close()
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, git.SetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", "This is a new note", "Test", "test@test.com"))
 | 
			
		||||
	require.NoError(t, git.SetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", "This is a new note", "Test", "test@test.com"))
 | 
			
		||||
 | 
			
		||||
	note := git.Note{}
 | 
			
		||||
	err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, []byte("This is a new note\n"), note.Message)
 | 
			
		||||
	assert.Equal(t, "Test", note.Commit.Author.Name)
 | 
			
		||||
| 
						 | 
				
			
			@ -97,10 +93,10 @@ func TestRemoveNote(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	defer bareRepo1.Close()
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, git.RemoveNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653"))
 | 
			
		||||
	require.NoError(t, git.RemoveNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653"))
 | 
			
		||||
 | 
			
		||||
	note := git.Note{}
 | 
			
		||||
	err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
 | 
			
		||||
	require.Error(t, err)
 | 
			
		||||
	assert.IsType(t, git.ErrNotExist{}, err)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@ import (
 | 
			
		|||
 | 
			
		||||
// This unit test relies on the implementation detail of CatFileBatch.
 | 
			
		||||
func TestCatFileBatch(t *testing.T) {
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	repo, err := OpenRepository(ctx, "./tests/repos/repo1_bare")
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ func TestCatFileBatch(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
// This unit test relies on the implementation detail of CatFileBatchCheck.
 | 
			
		||||
func TestCatFileBatchCheck(t *testing.T) {
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	repo, err := OpenRepository(ctx, "./tests/repos/repo1_bare")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,21 +33,21 @@ func TestRepoIsEmpty(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
func TestRepoGetDivergingCommits(t *testing.T) {
 | 
			
		||||
	bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
 | 
			
		||||
	do, err := GetDivergingCommits(context.Background(), bareRepo1Path, "master", "branch2")
 | 
			
		||||
	do, err := GetDivergingCommits(t.Context(), bareRepo1Path, "master", "branch2")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, DivergeObject{
 | 
			
		||||
		Ahead:  1,
 | 
			
		||||
		Behind: 5,
 | 
			
		||||
	}, do)
 | 
			
		||||
 | 
			
		||||
	do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "master")
 | 
			
		||||
	do, err = GetDivergingCommits(t.Context(), bareRepo1Path, "master", "master")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, DivergeObject{
 | 
			
		||||
		Ahead:  0,
 | 
			
		||||
		Behind: 0,
 | 
			
		||||
	}, do)
 | 
			
		||||
 | 
			
		||||
	do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "test")
 | 
			
		||||
	do, err = GetDivergingCommits(t.Context(), bareRepo1Path, "master", "test")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, DivergeObject{
 | 
			
		||||
		Ahead:  0,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package code
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"os"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +93,7 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
 | 
			
		|||
 | 
			
		||||
		for _, kw := range keywords {
 | 
			
		||||
			t.Run(kw.Keyword, func(t *testing.T) {
 | 
			
		||||
				total, res, langs, err := indexer.Search(context.TODO(), &internal.SearchOptions{
 | 
			
		||||
				total, res, langs, err := indexer.Search(t.Context(), &internal.SearchOptions{
 | 
			
		||||
					RepoIDs: kw.RepoIDs,
 | 
			
		||||
					Keyword: kw.Keyword,
 | 
			
		||||
					Paginator: &db.ListOptions{
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +116,7 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
 | 
			
		|||
			})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, indexer.Delete(context.Background(), repoID))
 | 
			
		||||
		require.NoError(t, indexer.Delete(t.Context(), repoID))
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +126,7 @@ func TestBleveIndexAndSearch(t *testing.T) {
 | 
			
		|||
	dir := t.TempDir()
 | 
			
		||||
 | 
			
		||||
	idx := bleve.NewIndexer(dir)
 | 
			
		||||
	_, err := idx.Init(context.Background())
 | 
			
		||||
	_, err := idx.Init(t.Context())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if idx != nil {
 | 
			
		||||
			idx.Close()
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +148,7 @@ func TestESIndexAndSearch(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	indexer := elasticsearch.NewIndexer(u, "gitea_codes")
 | 
			
		||||
	if _, err := indexer.Init(context.Background()); err != nil {
 | 
			
		||||
	if _, err := indexer.Init(t.Context()); err != nil {
 | 
			
		||||
		if indexer != nil {
 | 
			
		||||
			indexer.Close()
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package issues
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models/db"
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +81,7 @@ func searchIssueWithKeyword(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +126,7 @@ func searchIssueInRepo(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +197,7 @@ func searchIssueByID(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +222,7 @@ func searchIssueIsPull(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -249,7 +248,7 @@ func searchIssueIsClosed(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -274,7 +273,7 @@ func searchIssueByMilestoneID(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -306,7 +305,7 @@ func searchIssueByLabelID(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -326,7 +325,7 @@ func searchIssueByTime(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +345,7 @@ func searchIssueWithOrder(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -378,7 +377,7 @@ func searchIssueInProject(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, _, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			@ -402,7 +401,7 @@ func searchIssueWithPaginator(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		issueIDs, total, err := SearchIssues(context.TODO(), &test.opts)
 | 
			
		||||
		issueIDs, total, err := SearchIssues(t.Context(), &test.opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, test.expectedIDs, issueIDs)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,10 +24,10 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestIndexer(t *testing.T, indexer internal.Indexer) {
 | 
			
		||||
	_, err := indexer.Init(context.Background())
 | 
			
		||||
	_, err := indexer.Init(t.Context())
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, indexer.Ping(context.Background()))
 | 
			
		||||
	require.NoError(t, indexer.Ping(t.Context()))
 | 
			
		||||
 | 
			
		||||
	var (
 | 
			
		||||
		ids  []int64
 | 
			
		||||
| 
						 | 
				
			
			@ -39,32 +39,32 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
 | 
			
		|||
			ids = append(ids, v.ID)
 | 
			
		||||
			data[v.ID] = v
 | 
			
		||||
		}
 | 
			
		||||
		require.NoError(t, indexer.Index(context.Background(), d...))
 | 
			
		||||
		require.NoError(t, indexer.Index(t.Context(), d...))
 | 
			
		||||
		require.NoError(t, waitData(indexer, int64(len(data))))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defer func() {
 | 
			
		||||
		require.NoError(t, indexer.Delete(context.Background(), ids...))
 | 
			
		||||
		require.NoError(t, indexer.Delete(t.Context(), ids...))
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	for _, c := range cases {
 | 
			
		||||
		t.Run(c.Name, func(t *testing.T) {
 | 
			
		||||
			if len(c.ExtraData) > 0 {
 | 
			
		||||
				require.NoError(t, indexer.Index(context.Background(), c.ExtraData...))
 | 
			
		||||
				require.NoError(t, indexer.Index(t.Context(), c.ExtraData...))
 | 
			
		||||
				for _, v := range c.ExtraData {
 | 
			
		||||
					data[v.ID] = v
 | 
			
		||||
				}
 | 
			
		||||
				require.NoError(t, waitData(indexer, int64(len(data))))
 | 
			
		||||
				defer func() {
 | 
			
		||||
					for _, v := range c.ExtraData {
 | 
			
		||||
						require.NoError(t, indexer.Delete(context.Background(), v.ID))
 | 
			
		||||
						require.NoError(t, indexer.Delete(t.Context(), v.ID))
 | 
			
		||||
						delete(data, v.ID)
 | 
			
		||||
					}
 | 
			
		||||
					require.NoError(t, waitData(indexer, int64(len(data))))
 | 
			
		||||
				}()
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			result, err := indexer.Search(context.Background(), c.SearchOptions)
 | 
			
		||||
			result, err := indexer.Search(t.Context(), c.SearchOptions)
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
			if c.Expected != nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
 | 
			
		|||
 | 
			
		||||
			// test counting
 | 
			
		||||
			c.SearchOptions.Paginator = &db.ListOptions{PageSize: 0}
 | 
			
		||||
			countResult, err := indexer.Search(context.Background(), c.SearchOptions)
 | 
			
		||||
			countResult, err := indexer.Search(t.Context(), c.SearchOptions)
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Empty(t, countResult.Hits)
 | 
			
		||||
			assert.Equal(t, result.Total, countResult.Total)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package stats
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +41,7 @@ func TestRepoStatsIndex(t *testing.T) {
 | 
			
		|||
	err = UpdateRepoIndexer(repo)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, queue.GetManager().FlushAll(context.Background(), 5*time.Second))
 | 
			
		||||
	require.NoError(t, queue.GetManager().FlushAll(t.Context(), 5*time.Second))
 | 
			
		||||
 | 
			
		||||
	status, err := repo_model.GetIndexerStatus(db.DefaultContext, repo, repo_model.RepoIndexerTypeStats)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ func TestHTTPClientDownload(t *testing.T) {
 | 
			
		|||
				},
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			err := client.Download(context.Background(), []Pointer{p}, func(p Pointer, content io.ReadCloser, objectError error) error {
 | 
			
		||||
			err := client.Download(t.Context(), []Pointer{p}, func(p Pointer, content io.ReadCloser, objectError error) error {
 | 
			
		||||
				if objectError != nil {
 | 
			
		||||
					return objectError
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -349,7 +349,7 @@ func TestHTTPClientUpload(t *testing.T) {
 | 
			
		|||
				},
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			err := client.Upload(context.Background(), []Pointer{p}, func(p Pointer, objectError error) (io.ReadCloser, error) {
 | 
			
		||||
			err := client.Upload(t.Context(), []Pointer{p}, func(p Pointer, objectError error) (io.ReadCloser, error) {
 | 
			
		||||
				return io.NopCloser(new(bytes.Buffer)), objectError
 | 
			
		||||
			})
 | 
			
		||||
			if c.expectedError != "" {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package lfs
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +94,7 @@ func TestBasicTransferAdapter(t *testing.T) {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		for n, c := range cases {
 | 
			
		||||
			_, err := a.Download(context.Background(), c.link)
 | 
			
		||||
			_, err := a.Download(t.Context(), c.link)
 | 
			
		||||
			if len(c.expectederror) > 0 {
 | 
			
		||||
				assert.Contains(t, err.Error(), c.expectederror, "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror)
 | 
			
		||||
			} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +127,7 @@ func TestBasicTransferAdapter(t *testing.T) {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		for n, c := range cases {
 | 
			
		||||
			err := a.Upload(context.Background(), c.link, p, bytes.NewBufferString("dummy"))
 | 
			
		||||
			err := a.Upload(t.Context(), c.link, p, bytes.NewBufferString("dummy"))
 | 
			
		||||
			if len(c.expectederror) > 0 {
 | 
			
		||||
				assert.Contains(t, err.Error(), c.expectederror, "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror)
 | 
			
		||||
			} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +160,7 @@ func TestBasicTransferAdapter(t *testing.T) {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		for n, c := range cases {
 | 
			
		||||
			err := a.Verify(context.Background(), c.link, p)
 | 
			
		||||
			err := a.Verify(t.Context(), c.link, p)
 | 
			
		||||
			if len(c.expectederror) > 0 {
 | 
			
		||||
				assert.Contains(t, err.Error(), c.expectederror, "case %d: '%s' should contain '%s'", n, err.Error(), c.expectederror)
 | 
			
		||||
			} else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package log_test
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +22,7 @@ func TestBufferLogger(t *testing.T) {
 | 
			
		|||
		Expression: expected,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	logger := log.NewLoggerWithWriters(context.Background(), "test", bufferWriter)
 | 
			
		||||
	logger := log.NewLoggerWithWriters(t.Context(), "test", bufferWriter)
 | 
			
		||||
 | 
			
		||||
	logger.SendLogEvent(&log.Event{
 | 
			
		||||
		Level:         log.INFO,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package log
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net"
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +40,7 @@ func TestConnLogger(t *testing.T) {
 | 
			
		|||
	level := INFO
 | 
			
		||||
	flags := LstdFlags | LUTC | Lfuncname
 | 
			
		||||
 | 
			
		||||
	logger := NewLoggerWithWriters(context.Background(), "test", NewEventWriterConn("test-conn", WriterMode{
 | 
			
		||||
	logger := NewLoggerWithWriters(t.Context(), "test", NewEventWriterConn("test-conn", WriterMode{
 | 
			
		||||
		Level:        level,
 | 
			
		||||
		Prefix:       prefix,
 | 
			
		||||
		Flags:        FlagsFromBits(flags),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func Test_getGoroutineLabels(t *testing.T) {
 | 
			
		||||
	pprof.Do(context.Background(), pprof.Labels(), func(ctx context.Context) {
 | 
			
		||||
	pprof.Do(t.Context(), pprof.Labels(), func(ctx context.Context) {
 | 
			
		||||
		currentLabels := getGoroutineLabels()
 | 
			
		||||
		pprof.ForLabels(ctx, func(key, value string) bool {
 | 
			
		||||
			assert.EqualValues(t, value, currentLabels[key])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package log
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +52,7 @@ func newDummyWriter(name string, level Level, delay time.Duration) *dummyWriter
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestLogger(t *testing.T) {
 | 
			
		||||
	logger := NewLoggerWithWriters(context.Background(), "test")
 | 
			
		||||
	logger := NewLoggerWithWriters(t.Context(), "test")
 | 
			
		||||
 | 
			
		||||
	dump := logger.DumpWriters()
 | 
			
		||||
	assert.Empty(t, dump)
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +87,7 @@ func TestLogger(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestLoggerPause(t *testing.T) {
 | 
			
		||||
	logger := NewLoggerWithWriters(context.Background(), "test")
 | 
			
		||||
	logger := NewLoggerWithWriters(t.Context(), "test")
 | 
			
		||||
 | 
			
		||||
	w1 := newDummyWriter("dummy-1", DEBUG, 0)
 | 
			
		||||
	logger.AddWriters(w1)
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +116,7 @@ func (t testLogString) LogString() string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestLoggerLogString(t *testing.T) {
 | 
			
		||||
	logger := NewLoggerWithWriters(context.Background(), "test")
 | 
			
		||||
	logger := NewLoggerWithWriters(t.Context(), "test")
 | 
			
		||||
 | 
			
		||||
	w1 := newDummyWriter("dummy-1", DEBUG, 0)
 | 
			
		||||
	w1.Mode.Colorize = true
 | 
			
		||||
| 
						 | 
				
			
			@ -130,7 +129,7 @@ func TestLoggerLogString(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestLoggerExpressionFilter(t *testing.T) {
 | 
			
		||||
	logger := NewLoggerWithWriters(context.Background(), "test")
 | 
			
		||||
	logger := NewLoggerWithWriters(t.Context(), "test")
 | 
			
		||||
 | 
			
		||||
	w1 := newDummyWriter("dummy-1", DEBUG, 0)
 | 
			
		||||
	w1.Mode.Expression = "foo.*"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -680,7 +680,7 @@ func TestRender_FilePreview(t *testing.T) {
 | 
			
		|||
	defer test.MockVariableValue(&setting.StaticRootPath, "../../")()
 | 
			
		||||
	defer test.MockVariableValue(&setting.Names, []string{"english"})()
 | 
			
		||||
	defer test.MockVariableValue(&setting.Langs, []string{"en-US"})()
 | 
			
		||||
	translation.InitLocales(context.Background())
 | 
			
		||||
	translation.InitLocales(t.Context())
 | 
			
		||||
 | 
			
		||||
	setting.AppURL = markup.TestAppURL
 | 
			
		||||
	markup.Init(&markup.ProcessorHelper{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1190,7 +1190,7 @@ space</p>
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for i, c := range cases {
 | 
			
		||||
		result, err := markdown.RenderString(&markup.RenderContext{Ctx: context.Background(), Links: c.Links, IsWiki: c.IsWiki}, input)
 | 
			
		||||
		result, err := markdown.RenderString(&markup.RenderContext{Ctx: t.Context(), Links: c.Links, IsWiki: c.IsWiki}, input)
 | 
			
		||||
		require.NoError(t, err, "Unexpected error in testcase: %v", i)
 | 
			
		||||
		assert.Equal(t, template.HTML(c.Expected), result, "Unexpected result in testcase %v", i)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package process
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
| 
						 | 
				
			
			@ -12,13 +11,13 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestProcessStacktraces(t *testing.T) {
 | 
			
		||||
	_, _, finish := GetManager().AddContext(context.Background(), "Normal process")
 | 
			
		||||
	_, _, finish := GetManager().AddContext(t.Context(), "Normal process")
 | 
			
		||||
	defer finish()
 | 
			
		||||
	parentCtx, _, finish := GetManager().AddContext(context.Background(), "Children normal process")
 | 
			
		||||
	parentCtx, _, finish := GetManager().AddContext(t.Context(), "Children normal process")
 | 
			
		||||
	defer finish()
 | 
			
		||||
	_, _, finish = GetManager().AddContext(parentCtx, "Children process")
 | 
			
		||||
	defer finish()
 | 
			
		||||
	_, _, finish = GetManager().AddTypedContext(context.Background(), "System process", SystemProcessType, true)
 | 
			
		||||
	_, _, finish = GetManager().AddTypedContext(t.Context(), "System process", SystemProcessType, true)
 | 
			
		||||
	defer finish()
 | 
			
		||||
 | 
			
		||||
	t.Run("No flat with no system process", func(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ func TestGetManager(t *testing.T) {
 | 
			
		|||
func TestManager_AddContext(t *testing.T) {
 | 
			
		||||
	pm := Manager{processMap: make(map[IDType]*process), next: 1}
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	p1Ctx, _, finished := pm.AddContext(ctx, "foo")
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ func TestManager_AddContext(t *testing.T) {
 | 
			
		|||
func TestManager_Cancel(t *testing.T) {
 | 
			
		||||
	pm := Manager{processMap: make(map[IDType]*process), next: 1}
 | 
			
		||||
 | 
			
		||||
	ctx, _, finished := pm.AddContext(context.Background(), "foo")
 | 
			
		||||
	ctx, _, finished := pm.AddContext(t.Context(), "foo")
 | 
			
		||||
	defer finished()
 | 
			
		||||
 | 
			
		||||
	pm.Cancel(GetPID(ctx))
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ func TestManager_Cancel(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
	finished()
 | 
			
		||||
 | 
			
		||||
	ctx, cancel, finished := pm.AddContext(context.Background(), "foo")
 | 
			
		||||
	ctx, cancel, finished := pm.AddContext(t.Context(), "foo")
 | 
			
		||||
	defer finished()
 | 
			
		||||
 | 
			
		||||
	cancel()
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ func TestManager_Cancel(t *testing.T) {
 | 
			
		|||
func TestManager_Remove(t *testing.T) {
 | 
			
		||||
	pm := Manager{processMap: make(map[IDType]*process), next: 1}
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
 | 
			
		||||
	p1Ctx, _, finished := pm.AddContext(ctx, "foo")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ func testQueueBasic(t *testing.T, newFn func(cfg *BaseConfig) (baseQueue, error)
 | 
			
		|||
		q, err := newFn(cfg)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		ctx := context.Background()
 | 
			
		||||
		ctx := t.Context()
 | 
			
		||||
		_ = q.RemoveAll(ctx)
 | 
			
		||||
		cnt, err := q.Len(ctx)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +122,7 @@ func TestBaseDummy(t *testing.T) {
 | 
			
		|||
	q, err := newBaseDummy(&BaseConfig{}, true)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
	require.NoError(t, q.PushItem(ctx, []byte("foo")))
 | 
			
		||||
 | 
			
		||||
	cnt, err := q.Len(ctx)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package queue
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +80,7 @@ MAX_WORKERS = 123
 | 
			
		|||
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	q1 := createWorkerPoolQueue[string](context.Background(), "no-such", cfgProvider, nil, false)
 | 
			
		||||
	q1 := createWorkerPoolQueue[string](t.Context(), "no-such", cfgProvider, nil, false)
 | 
			
		||||
	assert.Equal(t, "no-such", q1.GetName())
 | 
			
		||||
	assert.Equal(t, "dummy", q1.GetType()) // no handler, so it becomes dummy
 | 
			
		||||
	assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/dir1"), q1.baseConfig.DataFullDir)
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +96,7 @@ MAX_WORKERS = 123
 | 
			
		|||
	assert.Equal(t, "string", q1.GetItemTypeName())
 | 
			
		||||
	qid1 := GetManager().qidCounter
 | 
			
		||||
 | 
			
		||||
	q2 := createWorkerPoolQueue(context.Background(), "sub", cfgProvider, func(s ...int) (unhandled []int) { return nil }, false)
 | 
			
		||||
	q2 := createWorkerPoolQueue(t.Context(), "sub", cfgProvider, func(s ...int) (unhandled []int) { return nil }, false)
 | 
			
		||||
	assert.Equal(t, "sub", q2.GetName())
 | 
			
		||||
	assert.Equal(t, "level", q2.GetType())
 | 
			
		||||
	assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/dir2"), q2.baseConfig.DataFullDir)
 | 
			
		||||
| 
						 | 
				
			
			@ -119,7 +118,7 @@ MAX_WORKERS = 123
 | 
			
		|||
	assert.Equal(t, 120, q1.workerMaxNum)
 | 
			
		||||
 | 
			
		||||
	stop := runWorkerPoolQueue(q2)
 | 
			
		||||
	require.NoError(t, GetManager().GetManagedQueue(qid2).FlushWithContext(context.Background(), 0))
 | 
			
		||||
	require.NoError(t, GetManager().FlushAll(context.Background(), 0))
 | 
			
		||||
	require.NoError(t, GetManager().GetManagedQueue(qid2).FlushWithContext(t.Context(), 0))
 | 
			
		||||
	require.NoError(t, GetManager().FlushAll(t.Context(), 0))
 | 
			
		||||
	stop()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package queue
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"sync"
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +58,7 @@ func TestWorkerPoolQueueUnhandled(t *testing.T) {
 | 
			
		|||
			testRecorder.Record("push:%v", i)
 | 
			
		||||
			require.NoError(t, q.Push(i))
 | 
			
		||||
		}
 | 
			
		||||
		require.NoError(t, q.FlushWithContext(context.Background(), 0))
 | 
			
		||||
		require.NoError(t, q.FlushWithContext(t.Context(), 0))
 | 
			
		||||
		stop()
 | 
			
		||||
 | 
			
		||||
		ok := true
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +166,7 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
 | 
			
		|||
 | 
			
		||||
		q, _ := newWorkerPoolQueueForTest("pr_patch_checker_test", queueSetting, testHandler, true)
 | 
			
		||||
		stop := runWorkerPoolQueue(q)
 | 
			
		||||
		require.NoError(t, q.FlushWithContext(context.Background(), 0))
 | 
			
		||||
		require.NoError(t, q.FlushWithContext(t.Context(), 0))
 | 
			
		||||
		stop()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ func AesEncrypt(key, text []byte) ([]byte, error) {
 | 
			
		|||
	if _, err = io.ReadFull(rand.Reader, iv); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("AesEncrypt unable to read IV: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
	cfb := cipher.NewCFBEncrypter(block, iv)
 | 
			
		||||
	cfb := cipher.NewCFBEncrypter(block, iv) //nolint:staticcheck
 | 
			
		||||
	cfb.XORKeyStream(ciphertext[aes.BlockSize:], []byte(b))
 | 
			
		||||
	return ciphertext, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ func AesDecrypt(key, text []byte) ([]byte, error) {
 | 
			
		|||
	}
 | 
			
		||||
	iv := text[:aes.BlockSize]
 | 
			
		||||
	text = text[aes.BlockSize:]
 | 
			
		||||
	cfb := cipher.NewCFBDecrypter(block, iv)
 | 
			
		||||
	cfb := cipher.NewCFBDecrypter(block, iv) //nolint:staticcheck
 | 
			
		||||
	cfb.XORKeyStream(text, text)
 | 
			
		||||
	data, err := base64.StdEncoding.DecodeString(string(text))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,12 +46,12 @@ var testMetas = map[string]string{
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestApostrophesInMentions(t *testing.T) {
 | 
			
		||||
	rendered := RenderMarkdownToHtml(context.Background(), "@mention-user's comment")
 | 
			
		||||
	rendered := RenderMarkdownToHtml(t.Context(), "@mention-user's comment")
 | 
			
		||||
	assert.EqualValues(t, template.HTML("<p><a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a>'s comment</p>\n"), rendered)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestNonExistantUserMention(t *testing.T) {
 | 
			
		||||
	rendered := RenderMarkdownToHtml(context.Background(), "@ThisUserDoesNotExist @mention-user")
 | 
			
		||||
	rendered := RenderMarkdownToHtml(t.Context(), "@ThisUserDoesNotExist @mention-user")
 | 
			
		||||
	assert.EqualValues(t, template.HTML("<p>@ThisUserDoesNotExist <a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a></p>\n"), rendered)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ func TestRenderCommitBody(t *testing.T) {
 | 
			
		|||
		{
 | 
			
		||||
			name: "multiple lines",
 | 
			
		||||
			args: args{
 | 
			
		||||
				ctx: context.Background(),
 | 
			
		||||
				ctx: t.Context(),
 | 
			
		||||
				msg: "first line\nsecond line",
 | 
			
		||||
			},
 | 
			
		||||
			want: "second line",
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ func TestRenderCommitBody(t *testing.T) {
 | 
			
		|||
		{
 | 
			
		||||
			name: "multiple lines with leading newlines",
 | 
			
		||||
			args: args{
 | 
			
		||||
				ctx: context.Background(),
 | 
			
		||||
				ctx: t.Context(),
 | 
			
		||||
				msg: "\n\n\n\nfirst line\nsecond line",
 | 
			
		||||
			},
 | 
			
		||||
			want: "second line",
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ func TestRenderCommitBody(t *testing.T) {
 | 
			
		|||
		{
 | 
			
		||||
			name: "multiple lines with trailing newlines",
 | 
			
		||||
			args: args{
 | 
			
		||||
				ctx: context.Background(),
 | 
			
		||||
				ctx: t.Context(),
 | 
			
		||||
				msg: "first line\nsecond line\n\n\n",
 | 
			
		||||
			},
 | 
			
		||||
			want: "second line",
 | 
			
		||||
| 
						 | 
				
			
			@ -117,19 +117,19 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
 | 
			
		|||
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
 | 
			
		||||
  space
 | 
			
		||||
` + "`code <span class=\"emoji\" aria-label=\"thumbs up\" data-alias=\"+1\">👍</span> <a href=\"/user13/repo11/issues/123\" class=\"ref-issue\">#123</a> code`"
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitBody(context.Background(), testInput, testMetas))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitBody(t.Context(), testInput, testMetas))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderCommitMessage(t *testing.T) {
 | 
			
		||||
	expected := `space <a href="/mention-user" class="mention">@mention-user</a>  `
 | 
			
		||||
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitMessage(context.Background(), testInput, testMetas))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitMessage(t.Context(), testInput, testMetas))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderCommitMessageLinkSubject(t *testing.T) {
 | 
			
		||||
	expected := `<a href="https://example.com/link" class="default-link muted">space </a><a href="/mention-user" class="mention">@mention-user</a>`
 | 
			
		||||
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitMessageLinkSubject(context.Background(), testInput, "https://example.com/link", testMetas))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderCommitMessageLinkSubject(t.Context(), testInput, "https://example.com/link", testMetas))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderIssueTitle(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +155,7 @@ mail@domain.com
 | 
			
		|||
  space
 | 
			
		||||
<code class="inline-code-block">code :+1: #123 code</code>
 | 
			
		||||
`
 | 
			
		||||
	assert.EqualValues(t, expected, RenderIssueTitle(context.Background(), testInput, testMetas))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderIssueTitle(t.Context(), testInput, testMetas))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderRefIssueTitle(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ mail@domain.com
 | 
			
		|||
  space
 | 
			
		||||
<code class="inline-code-block">code :+1: #123 code</code>
 | 
			
		||||
`
 | 
			
		||||
	assert.EqualValues(t, expected, RenderRefIssueTitle(context.Background(), testInput))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderRefIssueTitle(t.Context(), testInput))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderMarkdownToHtml(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +207,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
 | 
			
		|||
space
 | 
			
		||||
<code>code :+1: #123 code</code></p>
 | 
			
		||||
`
 | 
			
		||||
	assert.EqualValues(t, expected, RenderMarkdownToHtml(context.Background(), testInput))
 | 
			
		||||
	assert.EqualValues(t, expected, RenderMarkdownToHtml(t.Context(), testInput))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRenderLabels(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -471,7 +471,7 @@ func PrintCurrentTest(t testing.TB, skip ...int) func() {
 | 
			
		|||
				_, _ = fmt.Fprintf(os.Stdout, "+++ %s ... still flushing after %v ...\n", t.Name(), SlowFlush)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
		if err := queue.GetManager().FlushAll(context.Background(), time.Minute); err != nil {
 | 
			
		||||
		if err := queue.GetManager().FlushAll(t.Context(), time.Minute); err != nil {
 | 
			
		||||
			t.Errorf("Flushing queues failed with error %v", err)
 | 
			
		||||
		}
 | 
			
		||||
		timer.Stop()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package ping
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +50,7 @@ func MainServiceTest(t *testing.T, h http.Handler) {
 | 
			
		|||
	clients := []pingv1connect.PingServiceClient{connectClient, grpcClient, grpcWebClient}
 | 
			
		||||
	t.Run("ping request", func(t *testing.T) {
 | 
			
		||||
		for _, client := range clients {
 | 
			
		||||
			result, err := client.Ping(context.Background(), connect.NewRequest(&pingv1.PingRequest{
 | 
			
		||||
			result, err := client.Ping(t.Context(), connect.NewRequest(&pingv1.PingRequest{
 | 
			
		||||
				Data: "foobar",
 | 
			
		||||
			}))
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package common
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +20,7 @@ import (
 | 
			
		|||
func TestRenderPanicErrorPage(t *testing.T) {
 | 
			
		||||
	w := httptest.NewRecorder()
 | 
			
		||||
	req := &http.Request{URL: &url.URL{}}
 | 
			
		||||
	req = req.WithContext(middleware.WithContextData(context.Background()))
 | 
			
		||||
	req = req.WithContext(middleware.WithContextData(t.Context()))
 | 
			
		||||
	RenderPanicErrorPage(w, req, errors.New("fake panic error (for test only)"))
 | 
			
		||||
	respContent := w.Body.String()
 | 
			
		||||
	assert.Contains(t, respContent, `class="page-content status-page-500"`)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package private
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models/unittest"
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +17,7 @@ var testReposDir = "tests/repos/"
 | 
			
		|||
func TestVerifyCommits(t *testing.T) {
 | 
			
		||||
	unittest.PrepareTestEnv(t)
 | 
			
		||||
 | 
			
		||||
	gitRepo, err := git.OpenRepository(context.Background(), testReposDir+"repo1_hook_verification")
 | 
			
		||||
	gitRepo, err := git.OpenRepository(t.Context(), testReposDir+"repo1_hook_verification")
 | 
			
		||||
	defer gitRepo.Close()
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package actions
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	actions_model "code.gitea.io/gitea/models/actions"
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +19,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)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, ret, 1)
 | 
			
		||||
	assert.Contains(t, ret, "job1")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package auth
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models/unittest"
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +26,7 @@ func TestUserIDFromToken(t *testing.T) {
 | 
			
		|||
		ds := make(middleware.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)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ func cleanUpUsers(ctx context.Context, users []*user_model.User) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestAdminNotificationMail_test(t *testing.T) {
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	users := getTestUsers(t)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,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(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct 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,
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,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(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct context
 | 
			
		||||
		Issue:   issue, Doer: doer, ActionType: activities_model.ActionCreateIssue,
 | 
			
		||||
		Content: "test body",
 | 
			
		||||
	}, "en-US", recipients, false, "issue create")
 | 
			
		||||
| 
						 | 
				
			
			@ -168,7 +168,7 @@ func TestMailerIssueTemplate(t *testing.T) {
 | 
			
		|||
		t.Helper()
 | 
			
		||||
		recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}}
 | 
			
		||||
 | 
			
		||||
		ctx.Context = context.Background()
 | 
			
		||||
		ctx.Context = t.Context()
 | 
			
		||||
		fromMention := false
 | 
			
		||||
		msgs, err := composeIssueCommentMessages(ctx, "en-US", recipients, fromMention, "TestMailerIssueTemplate")
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			@ -266,14 +266,14 @@ func TestTemplateSelection(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	msg := testComposeIssueCommentMessage(t, &mailCommentContext{
 | 
			
		||||
		Context: context.TODO(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct 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(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct context
 | 
			
		||||
		Issue:   issue, Doer: doer, ActionType: activities_model.ActionCommentIssue,
 | 
			
		||||
		Content: "test body", Comment: comment,
 | 
			
		||||
	}, recipients, false, "TestTemplateSelection")
 | 
			
		||||
| 
						 | 
				
			
			@ -282,14 +282,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(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct 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(), // TODO: use a correct context
 | 
			
		||||
		Context: t.Context(), // TODO: use a correct context
 | 
			
		||||
		Issue:   issue, Doer: doer, ActionType: activities_model.ActionCloseIssue,
 | 
			
		||||
		Content: "test body", Comment: comment,
 | 
			
		||||
	}, recipients, false, "TestTemplateSelection")
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +309,7 @@ func TestTemplateServices(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
		recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}}
 | 
			
		||||
		msg := testComposeIssueCommentMessage(t, &mailCommentContext{
 | 
			
		||||
			Context: context.TODO(), // TODO: use a correct context
 | 
			
		||||
			Context: t.Context(), // TODO: use a correct context
 | 
			
		||||
			Issue:   issue, Doer: doer, ActionType: actionType,
 | 
			
		||||
			Content: "test body", Comment: comment,
 | 
			
		||||
		}, recipients, fromMention, "TestTemplateServices")
 | 
			
		||||
| 
						 | 
				
			
			@ -353,7 +353,7 @@ func TestGenerateAdditionalHeaders(t *testing.T) {
 | 
			
		|||
	defer MockMailSettings(nil)()
 | 
			
		||||
	doer, _, issue, _ := prepareMailerTest(t)
 | 
			
		||||
 | 
			
		||||
	ctx := &mailCommentContext{Context: context.TODO() /* TODO: use a correct context */, Issue: issue, Doer: doer}
 | 
			
		||||
	ctx := &mailCommentContext{Context: t.Context() /* TODO: use a correct context */, Issue: issue, Doer: doer}
 | 
			
		||||
	recipient := &user_model.User{Name: "test", Email: "test@gitea.com"}
 | 
			
		||||
 | 
			
		||||
	headers := generateAdditionalHeaders(ctx, "dummy-reason", recipient)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package markup
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -33,10 +32,10 @@ func TestProcessorHelper(t *testing.T) {
 | 
			
		|||
	unittest.AssertCount(t, &user.User{Name: userNoSuch}, 0)
 | 
			
		||||
 | 
			
		||||
	// when using general context, use user's visibility to check
 | 
			
		||||
	assert.True(t, ProcessorHelper().IsUsernameMentionable(context.Background(), userPublic))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(context.Background(), userLimited))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(context.Background(), userPrivate))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(context.Background(), userNoSuch))
 | 
			
		||||
	assert.True(t, ProcessorHelper().IsUsernameMentionable(t.Context(), userPublic))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(t.Context(), userLimited))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(t.Context(), userPrivate))
 | 
			
		||||
	assert.False(t, ProcessorHelper().IsUsernameMentionable(t.Context(), userNoSuch))
 | 
			
		||||
 | 
			
		||||
	// when using web context, use user.IsUserVisibleToViewer to check
 | 
			
		||||
	req, err := http.NewRequest("GET", "/", nil)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"os"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +32,7 @@ func TestCodebaseDownloadRepo(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	factory := &CodebaseDownloaderFactory{}
 | 
			
		||||
	downloader, err := factory.New(context.Background(), base.MigrateOptions{
 | 
			
		||||
	downloader, err := factory.New(t.Context(), base.MigrateOptions{
 | 
			
		||||
		CloneAddr:    u.String(),
 | 
			
		||||
		AuthUsername: apiUser,
 | 
			
		||||
		AuthPassword: apiPassword,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"os"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -24,7 +23,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
 | 
			
		|||
	server := unittest.NewMockWebServer(t, "https://gitea.com", fixturePath, giteaToken != "")
 | 
			
		||||
	defer server.Close()
 | 
			
		||||
 | 
			
		||||
	downloader, err := NewGiteaDownloader(context.Background(), server.URL, "gitea/test_repo", "", "", giteaToken)
 | 
			
		||||
	downloader, err := NewGiteaDownloader(t.Context(), server.URL, "gitea/test_repo", "", "", giteaToken)
 | 
			
		||||
	if downloader == nil {
 | 
			
		||||
		t.Fatal("NewGitlabDownloader is nil")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +132,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
 | 
			
		|||
	user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
 | 
			
		||||
 | 
			
		||||
	repoName := "migrated"
 | 
			
		||||
	uploader := NewGiteaLocalUploader(context.Background(), doer, doer.Name, repoName)
 | 
			
		||||
	uploader := NewGiteaLocalUploader(t.Context(), doer, doer.Name, repoName)
 | 
			
		||||
	// call remapLocalUser
 | 
			
		||||
	uploader.sameApp = true
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +181,7 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) {
 | 
			
		|||
	doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
 | 
			
		||||
 | 
			
		||||
	repoName := "migrated"
 | 
			
		||||
	uploader := NewGiteaLocalUploader(context.Background(), doer, doer.Name, repoName)
 | 
			
		||||
	uploader := NewGiteaLocalUploader(t.Context(), doer, doer.Name, repoName)
 | 
			
		||||
	uploader.gitServiceType = structs.GiteaService
 | 
			
		||||
	// call remapExternalUser
 | 
			
		||||
	uploader.sameApp = false
 | 
			
		||||
| 
						 | 
				
			
			@ -301,7 +300,7 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	toRepoName := "migrated"
 | 
			
		||||
	uploader := NewGiteaLocalUploader(context.Background(), fromRepoOwner, fromRepoOwner.Name, toRepoName)
 | 
			
		||||
	uploader := NewGiteaLocalUploader(t.Context(), fromRepoOwner, fromRepoOwner.Name, toRepoName)
 | 
			
		||||
	uploader.gitServiceType = structs.GiteaService
 | 
			
		||||
	require.NoError(t, uploader.CreateRepo(&base.Repository{
 | 
			
		||||
		Description: "description",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"os"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +24,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
 | 
			
		|||
	server := unittest.NewMockWebServer(t, "https://api.github.com", fixturePath, token != "")
 | 
			
		||||
	defer server.Close()
 | 
			
		||||
 | 
			
		||||
	downloader := NewGithubDownloaderV3(context.Background(), server.URL, "", "", token, "go-gitea", "test_repo")
 | 
			
		||||
	downloader := NewGithubDownloaderV3(t.Context(), server.URL, "", "", token, "go-gitea", "test_repo")
 | 
			
		||||
	err := downloader.RefreshRate()
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ import (
 | 
			
		|||
	base "code.gitea.io/gitea/modules/migration"
 | 
			
		||||
	"code.gitea.io/gitea/modules/structs"
 | 
			
		||||
 | 
			
		||||
	"gitlab.com/gitlab-org/api/client-go"
 | 
			
		||||
	gitlab "gitlab.com/gitlab-org/api/client-go"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +18,7 @@ import (
 | 
			
		|||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"github.com/stretchr/testify/require"
 | 
			
		||||
	"gitlab.com/gitlab-org/api/client-go"
 | 
			
		||||
	gitlab "gitlab.com/gitlab-org/api/client-go"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGitlabDownloadRepo(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +30,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
 | 
			
		|||
	server := unittest.NewMockWebServer(t, "https://gitlab.com", fixturePath, gitlabPersonalAccessToken != "")
 | 
			
		||||
	defer server.Close()
 | 
			
		||||
 | 
			
		||||
	downloader, err := NewGitlabDownloader(context.Background(), server.URL, "forgejo/test_repo", "", "", gitlabPersonalAccessToken)
 | 
			
		||||
	downloader, err := NewGitlabDownloader(t.Context(), server.URL, "forgejo/test_repo", "", "", gitlabPersonalAccessToken)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("NewGitlabDownloader is nil: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -331,7 +330,7 @@ func TestGitlabSkippedIssueNumber(t *testing.T) {
 | 
			
		|||
	server := unittest.NewMockWebServer(t, "https://gitlab.com", fixturePath, gitlabPersonalAccessToken != "")
 | 
			
		||||
	defer server.Close()
 | 
			
		||||
 | 
			
		||||
	downloader, err := NewGitlabDownloader(context.Background(), server.URL, "troyengel/archbuild", "", "", gitlabPersonalAccessToken)
 | 
			
		||||
	downloader, err := NewGitlabDownloader(t.Context(), server.URL, "troyengel/archbuild", "", "", gitlabPersonalAccessToken)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("NewGitlabDownloader is nil: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -454,7 +453,7 @@ func TestGitlabGetReviews(t *testing.T) {
 | 
			
		|||
	repoID := 1324
 | 
			
		||||
 | 
			
		||||
	downloader := &GitlabDownloader{
 | 
			
		||||
		ctx:    context.Background(),
 | 
			
		||||
		ctx:    t.Context(),
 | 
			
		||||
		client: client,
 | 
			
		||||
		repoID: repoID,
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +29,7 @@ func TestGogsDownloadRepo(t *testing.T) {
 | 
			
		|||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	downloader := NewGogsDownloader(context.Background(), "https://try.gogs.io", "", "", gogsPersonalAccessToken, "lunnytest", "TESTREPO")
 | 
			
		||||
	downloader := NewGogsDownloader(t.Context(), "https://try.gogs.io", "", "", gogsPersonalAccessToken, "lunnytest", "TESTREPO")
 | 
			
		||||
	repo, err := downloader.GetRepoInfo()
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +206,7 @@ func TestGogsDownloaderFactory_New(t *testing.T) {
 | 
			
		|||
				AuthPassword: tt.args.AuthPassword,
 | 
			
		||||
				AuthToken:    tt.args.AuthToken,
 | 
			
		||||
			}
 | 
			
		||||
			got, err := f.New(context.Background(), opts)
 | 
			
		||||
			got, err := f.New(t.Context(), opts)
 | 
			
		||||
			if (err != nil) != tt.wantErr {
 | 
			
		||||
				t.Errorf("GogsDownloaderFactory.New() error = %v, wantErr %v", err, tt.wantErr)
 | 
			
		||||
				return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +22,7 @@ func TestOneDevDownloadRepo(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	u, _ := url.Parse("https://code.onedev.io")
 | 
			
		||||
	downloader := NewOneDevDownloader(context.Background(), u, "", "", "go-gitea-test_repo")
 | 
			
		||||
	downloader := NewOneDevDownloader(t.Context(), u, "", "", "go-gitea-test_repo")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("NewOneDevDownloader is nil: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package pull
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +33,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	cfg, err := setting.GetQueueSettings(setting.CfgProvider, "pr_patch_checker")
 | 
			
		||||
	require.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)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package repository_test
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +40,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.Time{}, // ensure that the models/fixtures/lfs_meta_object.yml objects are considered as well
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	webhook_model "code.gitea.io/gitea/models/webhook"
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +44,7 @@ func TestGiteaPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +73,7 @@ func TestGiteaPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +102,7 @@ func TestGiteaPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			@ -148,7 +147,7 @@ func TestForgejoPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +176,7 @@ func TestForgejoPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			@ -206,7 +205,7 @@ func TestForgejoPayload(t *testing.T) {
 | 
			
		|||
			PayloadVersion: 2,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(context.Background(), hook, task)
 | 
			
		||||
		req, reqBody, err := dh.NewRequest(t.Context(), hook, task)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		require.NotNil(t, req)
 | 
			
		||||
		require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,10 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +17,7 @@ import (
 | 
			
		|||
	webhook_model "code.gitea.io/gitea/models/webhook"
 | 
			
		||||
	"code.gitea.io/gitea/modules/hostmatcher"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	"code.gitea.io/gitea/modules/test"
 | 
			
		||||
	webhook_module "code.gitea.io/gitea/modules/webhook"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
| 
						 | 
				
			
			@ -26,16 +25,9 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func TestWebhookProxy(t *testing.T) {
 | 
			
		||||
	oldWebhook := setting.Webhook
 | 
			
		||||
	oldHTTPProxy := os.Getenv("http_proxy")
 | 
			
		||||
	oldHTTPSProxy := os.Getenv("https_proxy")
 | 
			
		||||
	t.Cleanup(func() {
 | 
			
		||||
		setting.Webhook = oldWebhook
 | 
			
		||||
		os.Setenv("http_proxy", oldHTTPProxy)
 | 
			
		||||
		os.Setenv("https_proxy", oldHTTPSProxy)
 | 
			
		||||
	})
 | 
			
		||||
	os.Unsetenv("http_proxy")
 | 
			
		||||
	os.Unsetenv("https_proxy")
 | 
			
		||||
	defer test.MockProtect(&setting.Webhook)()
 | 
			
		||||
	t.Setenv("http_proxy", "")
 | 
			
		||||
	t.Setenv("https_proxy", "")
 | 
			
		||||
 | 
			
		||||
	setting.Webhook.ProxyURL = "http://localhost:8080"
 | 
			
		||||
	setting.Webhook.ProxyURLFixed, _ = url.Parse(setting.Webhook.ProxyURL)
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +116,7 @@ func TestWebhookDeliverAuthorizationHeader(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	assert.NotNil(t, hookTask)
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, Deliver(context.Background(), hookTask))
 | 
			
		||||
	require.NoError(t, Deliver(t.Context(), hookTask))
 | 
			
		||||
	select {
 | 
			
		||||
	case <-done:
 | 
			
		||||
	case <-time.After(5 * time.Second):
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +182,7 @@ func TestWebhookDeliverHookTask(t *testing.T) {
 | 
			
		|||
		require.NoError(t, err)
 | 
			
		||||
		assert.NotNil(t, hookTask)
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, Deliver(context.Background(), hookTask))
 | 
			
		||||
		require.NoError(t, Deliver(t.Context(), hookTask))
 | 
			
		||||
		select {
 | 
			
		||||
		case <-done:
 | 
			
		||||
		case <-time.After(5 * time.Second):
 | 
			
		||||
| 
						 | 
				
			
			@ -216,7 +208,7 @@ func TestWebhookDeliverHookTask(t *testing.T) {
 | 
			
		|||
		require.NoError(t, err)
 | 
			
		||||
		assert.NotNil(t, hookTask)
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, Deliver(context.Background(), hookTask))
 | 
			
		||||
		require.NoError(t, Deliver(t.Context(), hookTask))
 | 
			
		||||
		select {
 | 
			
		||||
		case <-done:
 | 
			
		||||
		case <-time.After(5 * time.Second):
 | 
			
		||||
| 
						 | 
				
			
			@ -317,7 +309,7 @@ func TestWebhookDeliverSpecificTypes(t *testing.T) {
 | 
			
		|||
			require.NoError(t, err)
 | 
			
		||||
			assert.NotNil(t, hookTask)
 | 
			
		||||
 | 
			
		||||
			require.NoError(t, Deliver(context.Background(), hookTask))
 | 
			
		||||
			require.NoError(t, Deliver(t.Context(), hookTask))
 | 
			
		||||
			select {
 | 
			
		||||
			case gotBody := <-hc.gotBody:
 | 
			
		||||
				assert.NotEqual(t, string(data), string(gotBody), "request body must be different from the event payload")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 := dingtalkHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := dingtalkHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	webhook_model "code.gitea.io/gitea/models/webhook"
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +345,7 @@ func TestDiscordJSONPayload(t *testing.T) {
 | 
			
		|||
		PayloadVersion: 2,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	req, reqBody, err := discordHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := discordHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 := feishuHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := feishuHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 := matrixHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := matrixHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 := msteamsHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := msteamsHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +52,7 @@ func TestPackagistPayload(t *testing.T) {
 | 
			
		|||
				PayloadVersion: 2,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			req, reqBody, err := packagistHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
			req, reqBody, err := packagistHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
			require.NotNil(t, req)
 | 
			
		||||
			require.NotNil(t, reqBody)
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 := slackHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := slackHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package sourcehut
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +25,7 @@ func gitInit(t testing.TB) {
 | 
			
		|||
		return
 | 
			
		||||
	}
 | 
			
		||||
	t.Cleanup(test.MockVariableValue(&setting.Git.HomePath, t.TempDir()))
 | 
			
		||||
	require.NoError(t, git.InitSimple(context.Background()))
 | 
			
		||||
	require.NoError(t, git.InitSimple(t.Context()))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSourcehutBuildsPayload(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +371,7 @@ func TestSourcehutJSONPayload(t *testing.T) {
 | 
			
		|||
		PayloadVersion: 2,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	req, reqBody, err := BuildsHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := BuildsHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package webhook
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	webhook_model "code.gitea.io/gitea/models/webhook"
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +193,7 @@ func TestTelegramJSONPayload(t *testing.T) {
 | 
			
		|||
		PayloadVersion: 2,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	req, reqBody, err := telegramHandler{}.NewRequest(context.Background(), hook, task)
 | 
			
		||||
	req, reqBody, err := telegramHandler{}.NewRequest(t.Context(), hook, task)
 | 
			
		||||
	require.NotNil(t, req)
 | 
			
		||||
	require.NotNil(t, reqBody)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ func onForgejoRunTB(t testing.TB, callback func(testing.TB, *url.URL), prepare .
 | 
			
		|||
 | 
			
		||||
	defer func() {
 | 
			
		||||
		require.NoError(t, os.WriteFile(setting.CustomConf, conf, 0o644))
 | 
			
		||||
		ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
 | 
			
		||||
		ctx, cancel := context.WithTimeout(t.Context(), 2*time.Minute)
 | 
			
		||||
		s.Shutdown(ctx)
 | 
			
		||||
		cancel()
 | 
			
		||||
	}()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -416,7 +415,7 @@ jobs:
 | 
			
		|||
		actionTask := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: task.Id})
 | 
			
		||||
		actionRunJob := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: actionTask.JobID})
 | 
			
		||||
		actionRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{ID: actionRunJob.RunID})
 | 
			
		||||
		require.NoError(t, actionRun.LoadAttributes(context.Background()))
 | 
			
		||||
		require.NoError(t, actionRun.LoadAttributes(t.Context()))
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, user2.Name, gtCtx["actor"].GetStringValue())
 | 
			
		||||
		assert.Equal(t, setting.AppURL+"api/v1", gtCtx["api_url"].GetStringValue())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			@ -71,12 +70,12 @@ func TestActionsWebRouteLatestWorkflowRun(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
			// Verify that each points to the correct workflow.
 | 
			
		||||
			workflowOne := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: repo.ID, Index: 1})
 | 
			
		||||
			err := workflowOne.LoadAttributes(context.Background())
 | 
			
		||||
			err := workflowOne.LoadAttributes(t.Context())
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, workflowOneURI, workflowOne.HTMLURL())
 | 
			
		||||
 | 
			
		||||
			workflowTwo := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: repo.ID, Index: 2})
 | 
			
		||||
			err = workflowTwo.LoadAttributes(context.Background())
 | 
			
		||||
			err = workflowTwo.LoadAttributes(t.Context())
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, workflowTwoURI, workflowTwo.HTMLURL())
 | 
			
		||||
		})
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +140,7 @@ func TestActionsWebRouteLatestRun(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
		// Verify that it redirects to the run we just created
 | 
			
		||||
		workflow := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: repo.ID})
 | 
			
		||||
		err := workflow.LoadAttributes(context.Background())
 | 
			
		||||
		err := workflow.LoadAttributes(t.Context())
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		assert.Equal(t, workflow.HTMLURL(), resp.Header().Get("Location"))
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +169,7 @@ func TestActionsArtifactDeletion(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
		// Load the run we just created
 | 
			
		||||
		run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: repo.ID})
 | 
			
		||||
		err := run.LoadAttributes(context.Background())
 | 
			
		||||
		err := run.LoadAttributes(t.Context())
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		// Visit it's web view
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ func newMockRunnerClient(uuid, token string) *mockRunnerClient {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (r *mockRunner) doPing(t *testing.T) {
 | 
			
		||||
	resp, err := r.client.pingServiceClient.Ping(context.Background(), connect.NewRequest(&pingv1.PingRequest{
 | 
			
		||||
	resp, err := r.client.pingServiceClient.Ping(t.Context(), connect.NewRequest(&pingv1.PingRequest{
 | 
			
		||||
		Data: "mock-runner",
 | 
			
		||||
	}))
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ func (r *mockRunner) doPing(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
func (r *mockRunner) doRegister(t *testing.T, name, token string, labels []string) {
 | 
			
		||||
	r.doPing(t)
 | 
			
		||||
	resp, err := r.client.runnerServiceClient.Register(context.Background(), connect.NewRequest(&runnerv1.RegisterRequest{
 | 
			
		||||
	resp, err := r.client.runnerServiceClient.Register(t.Context(), connect.NewRequest(&runnerv1.RegisterRequest{
 | 
			
		||||
		Name:    name,
 | 
			
		||||
		Token:   token,
 | 
			
		||||
		Version: "mock-runner-version",
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +104,7 @@ func (r *mockRunner) fetchTask(t *testing.T, timeout ...time.Duration) *runnerv1
 | 
			
		|||
	ddl := time.Now().Add(fetchTimeout)
 | 
			
		||||
	var task *runnerv1.Task
 | 
			
		||||
	for time.Now().Before(ddl) {
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.FetchTask(context.Background(), connect.NewRequest(&runnerv1.FetchTaskRequest{
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.FetchTask(t.Context(), connect.NewRequest(&runnerv1.FetchTaskRequest{
 | 
			
		||||
			TasksVersion: 0,
 | 
			
		||||
		}))
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +127,7 @@ type mockTaskOutcome struct {
 | 
			
		|||
 | 
			
		||||
func (r *mockRunner) execTask(t *testing.T, task *runnerv1.Task, outcome *mockTaskOutcome) {
 | 
			
		||||
	for idx, lr := range outcome.logRows {
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.UpdateLog(context.Background(), connect.NewRequest(&runnerv1.UpdateLogRequest{
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.UpdateLog(t.Context(), connect.NewRequest(&runnerv1.UpdateLogRequest{
 | 
			
		||||
			TaskId: task.Id,
 | 
			
		||||
			Index:  int64(idx),
 | 
			
		||||
			Rows:   []*runnerv1.LogRow{lr},
 | 
			
		||||
| 
						 | 
				
			
			@ -138,7 +138,7 @@ func (r *mockRunner) execTask(t *testing.T, task *runnerv1.Task, outcome *mockTa
 | 
			
		|||
	}
 | 
			
		||||
	sentOutputKeys := make([]string, 0, len(outcome.outputs))
 | 
			
		||||
	for outputKey, outputValue := range outcome.outputs {
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.UpdateTask(context.Background(), connect.NewRequest(&runnerv1.UpdateTaskRequest{
 | 
			
		||||
		resp, err := r.client.runnerServiceClient.UpdateTask(t.Context(), connect.NewRequest(&runnerv1.UpdateTaskRequest{
 | 
			
		||||
			State: &runnerv1.TaskState{
 | 
			
		||||
				Id:     task.Id,
 | 
			
		||||
				Result: runnerv1.Result_RESULT_UNSPECIFIED,
 | 
			
		||||
| 
						 | 
				
			
			@ -150,7 +150,7 @@ func (r *mockRunner) execTask(t *testing.T, task *runnerv1.Task, outcome *mockTa
 | 
			
		|||
		assert.ElementsMatch(t, sentOutputKeys, resp.Msg.SentOutputs)
 | 
			
		||||
	}
 | 
			
		||||
	time.Sleep(outcome.execTime)
 | 
			
		||||
	resp, err := r.client.runnerServiceClient.UpdateTask(context.Background(), connect.NewRequest(&runnerv1.UpdateTaskRequest{
 | 
			
		||||
	resp, err := r.client.runnerServiceClient.UpdateTask(t.Context(), connect.NewRequest(&runnerv1.UpdateTaskRequest{
 | 
			
		||||
		State: &runnerv1.TaskState{
 | 
			
		||||
			Id:        task.Id,
 | 
			
		||||
			Result:    outcome.result,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strconv"
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +130,7 @@ func TestSourceId(t *testing.T) {
 | 
			
		|||
		LoginType:   auth_model.Plain,
 | 
			
		||||
		LoginSource: 23,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, testUser23)()
 | 
			
		||||
	defer createUser(t.Context(), t, testUser23)()
 | 
			
		||||
 | 
			
		||||
	session := loginUser(t, "user1")
 | 
			
		||||
	token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadAdmin)
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +162,7 @@ func TestAdminViewUsersSorted(t *testing.T) {
 | 
			
		|||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	createTimestamp := time.Now().Unix() - 1000
 | 
			
		||||
	updateTimestamp := time.Now().Unix() - 500
 | 
			
		||||
	sess := db.GetEngine(context.Background())
 | 
			
		||||
	sess := db.GetEngine(t.Context())
 | 
			
		||||
 | 
			
		||||
	// Create 10 users with login source 44
 | 
			
		||||
	for i := int64(1); i <= 10; i++ {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +285,7 @@ func doAPIMergePullRequestForm(t *testing.T, ctx APITestContext, owner, repo str
 | 
			
		|||
		if err.Message != "Please try again later" {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
		queue.GetManager().FlushAll(context.Background(), 5*time.Second)
 | 
			
		||||
		queue.GetManager().FlushAll(t.Context(), 5*time.Second)
 | 
			
		||||
		<-time.After(1 * time.Second)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ import (
 | 
			
		|||
 | 
			
		||||
func TestAPIPrivateNoServ(t *testing.T) {
 | 
			
		||||
	onGiteaRun(t, func(*testing.T, *url.URL) {
 | 
			
		||||
		ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
		ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
		defer cancel()
 | 
			
		||||
		key, user, err := private.ServNoCommand(ctx, 1)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ func TestAPIPrivateNoServ(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
func TestAPIPrivateServ(t *testing.T) {
 | 
			
		||||
	onGiteaRun(t, func(*testing.T, *url.URL) {
 | 
			
		||||
		ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
		ctx, cancel := context.WithCancel(t.Context())
 | 
			
		||||
		defer cancel()
 | 
			
		||||
 | 
			
		||||
		// Can push to a repo we own
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	stdCtx "context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +171,7 @@ func TestAPICreateFile(t *testing.T) {
 | 
			
		|||
			req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &createFileOptions).
 | 
			
		||||
				AddTokenAuth(token2)
 | 
			
		||||
			resp := MakeRequest(t, req, http.StatusCreated)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo1)
 | 
			
		||||
			commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName)
 | 
			
		||||
			latestCommit, _ := gitRepo.GetCommitByPath(treePath)
 | 
			
		||||
			expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String())
 | 
			
		||||
| 
						 | 
				
			
			@ -292,7 +291,7 @@ func TestAPICreateFile(t *testing.T) {
 | 
			
		|||
				AddTokenAuth(token2)
 | 
			
		||||
			resp = MakeRequest(t, req, http.StatusCreated)
 | 
			
		||||
			emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user2", Name: reponame}) // public repo
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), emptyRepo)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(t.Context(), emptyRepo)
 | 
			
		||||
			commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName)
 | 
			
		||||
			latestCommit, _ := gitRepo.GetCommitByPath(treePath)
 | 
			
		||||
			expectedFileResponse := getExpectedFileResponseForCreate("user2/"+reponame, commitID, treePath, latestCommit.ID.String())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	stdCtx "context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +134,7 @@ func TestAPIUpdateFile(t *testing.T) {
 | 
			
		|||
			req := NewRequestWithJSON(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &updateFileOptions).
 | 
			
		||||
				AddTokenAuth(token2)
 | 
			
		||||
			resp := MakeRequest(t, req, http.StatusOK)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo1)
 | 
			
		||||
			commitID, _ := gitRepo.GetBranchCommitID(updateFileOptions.NewBranchName)
 | 
			
		||||
			lasCommit, _ := gitRepo.GetCommitByPath(treePath)
 | 
			
		||||
			expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	stdCtx "context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +95,7 @@ func TestAPIChangeFiles(t *testing.T) {
 | 
			
		|||
			req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/contents", user2.Name, repo1.Name), &changeFilesOptions).
 | 
			
		||||
				AddTokenAuth(token2)
 | 
			
		||||
			resp := MakeRequest(t, req, http.StatusCreated)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1)
 | 
			
		||||
			gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo1)
 | 
			
		||||
			commitID, _ := gitRepo.GetBranchCommitID(changeFilesOptions.NewBranchName)
 | 
			
		||||
			createLasCommit, _ := gitRepo.GetCommitByPath(createTreePath)
 | 
			
		||||
			updateLastCommit, _ := gitRepo.GetCommitByPath(updateTreePath)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -320,7 +319,7 @@ func TestAPIEditOtherWikiPage(t *testing.T) {
 | 
			
		|||
	testCreateWiki(http.StatusForbidden)
 | 
			
		||||
 | 
			
		||||
	// Update the repo settings for user2's repo to enable globally writeable wiki
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
	repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
 | 
			
		||||
	var units []repo_model.RepoUnit
 | 
			
		||||
	units = append(units, repo_model.RepoUnit{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
| 
						 | 
				
			
			@ -244,7 +243,7 @@ func TestLDAPUserSync(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	addAuthSourceLDAP(t, "", "", "", "")
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	// Check if users exists
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
| 
						 | 
				
			
			@ -296,7 +295,7 @@ func TestLDAPUserSyncWithEmptyUsernameAttribute(t *testing.T) {
 | 
			
		|||
		MakeRequest(t, req, http.StatusSeeOther)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	authSource := unittest.AssertExistsAndLoadBean(t, &auth_model.Source{
 | 
			
		||||
		Name: payload["name"],
 | 
			
		||||
| 
						 | 
				
			
			@ -331,7 +330,7 @@ func TestLDAPUserSyncWithGroupFilter(t *testing.T) {
 | 
			
		|||
	u := otherLDAPUsers[0]
 | 
			
		||||
	testLoginFailed(t, u.UserName, u.Password, translation.NewLocale("en-US").TrString("form.username_password_incorrect"))
 | 
			
		||||
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	// Assert members of LDAP group "cn=git" are added
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +353,7 @@ func TestLDAPUserSyncWithGroupFilter(t *testing.T) {
 | 
			
		|||
	ldapConfig.GroupFilter = "(cn=ship_crew)"
 | 
			
		||||
	auth_model.UpdateSource(db.DefaultContext, ldapSource)
 | 
			
		||||
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
		if gitLDAPUser.UserName == "fry" || gitLDAPUser.UserName == "leela" || gitLDAPUser.UserName == "bender" {
 | 
			
		||||
| 
						 | 
				
			
			@ -393,7 +392,7 @@ func TestLDAPUserSSHKeySync(t *testing.T) {
 | 
			
		|||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	addAuthSourceLDAP(t, "sshPublicKey", "", "", "")
 | 
			
		||||
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	// Check if users has SSH keys synced
 | 
			
		||||
	for _, u := range gitLDAPUsers {
 | 
			
		||||
| 
						 | 
				
			
			@ -429,7 +428,7 @@ func TestLDAPGroupTeamSyncAddMember(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	team, err := organization.GetTeam(db.DefaultContext, org.ID, "team11")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
		user := unittest.AssertExistsAndLoadBean(t, &user_model.User{
 | 
			
		||||
			Name: gitLDAPUser.UserName,
 | 
			
		||||
| 
						 | 
				
			
			@ -518,7 +517,7 @@ func TestLDAPUserSyncInvalidMail(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	addAuthSourceLDAP(t, "", "nonexisting", "", "")
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	// Check if users exists
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
| 
						 | 
				
			
			@ -544,7 +543,7 @@ func TestLDAPUserSyncInvalidMailDefaultDomain(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	addAuthSourceLDAP(t, "", "nonexisting", "test.org", "")
 | 
			
		||||
	auth.SyncExternalUsers(context.Background(), true)
 | 
			
		||||
	auth.SyncExternalUsers(t.Context(), true)
 | 
			
		||||
 | 
			
		||||
	// Check if users exists
 | 
			
		||||
	for _, gitLDAPUser := range gitLDAPUsers {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	gocontext "context"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"os"
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +188,7 @@ func Test_CmdForgejo_Actions(t *testing.T) {
 | 
			
		|||
					require.NoError(t, err)
 | 
			
		||||
					if assert.EqualValues(t, testCase.uuid, uuid) {
 | 
			
		||||
						ownerName, repoName, found := strings.Cut(testCase.scope, "/")
 | 
			
		||||
						action, err := actions_model.GetRunnerByUUID(gocontext.Background(), uuid)
 | 
			
		||||
						action, err := actions_model.GetRunnerByUUID(t.Context(), uuid)
 | 
			
		||||
						require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
						user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: action.OwnerID})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ func TestF3_CmdMirror_LocalForgejo(t *testing.T) {
 | 
			
		|||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
	defer test.MockVariableValue(&setting.F3.Enabled, true)()
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	mirrorOptions := f3_tests_forge.GetFactory(options.Name)().NewOptions(t)
 | 
			
		||||
	mirrorTree := f3_generic.GetFactory("f3")(ctx, mirrorOptions)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +47,7 @@ func TestCodeOwner(t *testing.T) {
 | 
			
		|||
		r := fmt.Sprintf("%suser2/%s.git", u.String(), repo.Name)
 | 
			
		||||
		cloneURL, _ := url.Parse(r)
 | 
			
		||||
		cloneURL.User = url.UserPassword("user2", userPassword)
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(context.Background(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
 | 
			
		||||
 | 
			
		||||
		t.Run("Normal", func(t *testing.T) {
 | 
			
		||||
			defer tests.PrintCurrentTest(t)()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +20,6 @@ import (
 | 
			
		|||
	base "code.gitea.io/gitea/modules/migration"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	"code.gitea.io/gitea/modules/structs"
 | 
			
		||||
	"code.gitea.io/gitea/modules/util"
 | 
			
		||||
	"code.gitea.io/gitea/services/migrations"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
| 
						 | 
				
			
			@ -45,9 +43,7 @@ func TestDumpRestore(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
		reponame := "repo1"
 | 
			
		||||
 | 
			
		||||
		basePath, err := os.MkdirTemp("", reponame)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		defer util.RemoveAll(basePath)
 | 
			
		||||
		basePath := t.TempDir()
 | 
			
		||||
 | 
			
		||||
		repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: reponame})
 | 
			
		||||
		repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +54,7 @@ func TestDumpRestore(t *testing.T) {
 | 
			
		|||
		// Phase 1: dump repo1 from the Gitea instance to the filesystem
 | 
			
		||||
		//
 | 
			
		||||
 | 
			
		||||
		ctx := context.Background()
 | 
			
		||||
		ctx := t.Context()
 | 
			
		||||
		opts := migrations.MigrateOptions{
 | 
			
		||||
			GitServiceType: structs.GiteaService,
 | 
			
		||||
			Issues:         true,
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +66,7 @@ func TestDumpRestore(t *testing.T) {
 | 
			
		|||
			CloneAddr:      repo.CloneLink().HTTPS,
 | 
			
		||||
			RepoName:       reponame,
 | 
			
		||||
		}
 | 
			
		||||
		err = migrations.DumpRepository(ctx, basePath, repoOwner.Name, opts)
 | 
			
		||||
		err := migrations.DumpRepository(ctx, basePath, repoOwner.Name, opts)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		//
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ func onGiteaRun[T testing.TB](t T, callback func(T, *url.URL)) {
 | 
			
		|||
func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
 | 
			
		||||
	return func(t *testing.T) {
 | 
			
		||||
		t.Helper()
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(context.Background(), git.AllowLFSFiltersArgs(), u.String(), dstLocalPath, git.CloneRepoOptions{}))
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(t.Context(), git.AllowLFSFiltersArgs(), u.String(), dstLocalPath, git.CloneRepoOptions{}))
 | 
			
		||||
		exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.True(t, exist)
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
 | 
			
		|||
func doPartialGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
 | 
			
		||||
	return func(t *testing.T) {
 | 
			
		||||
		t.Helper()
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(context.Background(), git.AllowLFSFiltersArgs(), u.String(), dstLocalPath, git.CloneRepoOptions{
 | 
			
		||||
		require.NoError(t, git.CloneWithArgs(t.Context(), git.AllowLFSFiltersArgs(), u.String(), dstLocalPath, git.CloneRepoOptions{
 | 
			
		||||
			Filter: "blob:none",
 | 
			
		||||
		}))
 | 
			
		||||
		exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -347,7 +347,7 @@ func authSourcePayloadGitHubCustom(name string) map[string]string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func createRemoteAuthSource(t *testing.T, name, url, matchingSource string) *auth.Source {
 | 
			
		||||
	require.NoError(t, auth.CreateSource(context.Background(), &auth.Source{
 | 
			
		||||
	require.NoError(t, auth.CreateSource(t.Context(), &auth.Source{
 | 
			
		||||
		Type:     auth.Remote,
 | 
			
		||||
		Name:     name,
 | 
			
		||||
		IsActive: true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +119,7 @@ func TestViewIssuesKeyword(t *testing.T) {
 | 
			
		|||
		RepoID: repo.ID,
 | 
			
		||||
		Index:  1,
 | 
			
		||||
	})
 | 
			
		||||
	issues.UpdateIssueIndexer(context.Background(), issue.ID)
 | 
			
		||||
	issues.UpdateIssueIndexer(t.Context(), issue.ID)
 | 
			
		||||
	time.Sleep(time.Second * 1)
 | 
			
		||||
 | 
			
		||||
	const keyword = "first"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +157,7 @@ func TestLFSLockView(t *testing.T) {
 | 
			
		|||
		defer tests.PrintCurrentTest(t)()
 | 
			
		||||
 | 
			
		||||
		// make sure the display names are different, or the test is meaningless
 | 
			
		||||
		require.NoError(t, repo3.LoadOwner(context.Background()))
 | 
			
		||||
		require.NoError(t, repo3.LoadOwner(t.Context()))
 | 
			
		||||
		require.NotEqual(t, user2.DisplayName(), repo3.Owner.DisplayName())
 | 
			
		||||
 | 
			
		||||
		req := NewRequest(t, "GET", fmt.Sprintf("/%s/settings/lfs/locks", repo3.FullName()))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +81,7 @@ func TestLinguistSupport(t *testing.T) {
 | 
			
		|||
			err := stats.UpdateRepoIndexer(repo)
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
			require.NoError(t, queue.GetManager().FlushAll(context.Background(), 10*time.Second))
 | 
			
		||||
			require.NoError(t, queue.GetManager().FlushAll(t.Context(), 10*time.Second))
 | 
			
		||||
 | 
			
		||||
			status, err := repo_model.GetIndexerStatus(db.DefaultContext, repo, repo_model.RepoIndexerTypeStats)
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package migrations
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"compress/gzip"
 | 
			
		||||
	"context"
 | 
			
		||||
	"database/sql"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +86,7 @@ func initMigrationTest(t *testing.T) func() {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	require.NoError(t, git.InitFull(context.Background()))
 | 
			
		||||
	require.NoError(t, git.InitFull(t.Context()))
 | 
			
		||||
	setting.LoadDBSetting()
 | 
			
		||||
	setting.InitLoggersForTest()
 | 
			
		||||
	return deferFn
 | 
			
		||||
| 
						 | 
				
			
			@ -279,13 +278,13 @@ func doMigrationTest(t *testing.T, version string) {
 | 
			
		|||
 | 
			
		||||
	setting.InitSQLLoggersForCli(log.INFO)
 | 
			
		||||
 | 
			
		||||
	err := db.InitEngineWithMigration(context.Background(), wrappedMigrate)
 | 
			
		||||
	err := db.InitEngineWithMigration(t.Context(), wrappedMigrate)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	currentEngine.Close()
 | 
			
		||||
 | 
			
		||||
	beans, _ := db.NamesToBean()
 | 
			
		||||
 | 
			
		||||
	err = db.InitEngineWithMigration(context.Background(), func(x *xorm.Engine) error {
 | 
			
		||||
	err = db.InitEngineWithMigration(t.Context(), func(x *xorm.Engine) error {
 | 
			
		||||
		currentEngine = x
 | 
			
		||||
		return migrate_base.RecreateTables(beans...)(x)
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			@ -293,7 +292,7 @@ func doMigrationTest(t *testing.T, version string) {
 | 
			
		|||
	currentEngine.Close()
 | 
			
		||||
 | 
			
		||||
	// We do this a second time to ensure that there is not a problem with retained indices
 | 
			
		||||
	err = db.InitEngineWithMigration(context.Background(), func(x *xorm.Engine) error {
 | 
			
		||||
	err = db.InitEngineWithMigration(t.Context(), func(x *xorm.Engine) error {
 | 
			
		||||
		currentEngine = x
 | 
			
		||||
		return migrate_base.RecreateTables(beans...)(x)
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models/db"
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +49,7 @@ func TestMirrorPull(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	assert.True(t, mirrorRepo.IsMirror, "expected pull-mirror repo to be marked as a mirror immediately after its creation")
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
 | 
			
		||||
	mirror, err := repo_service.MigrateRepositoryGitData(ctx, user, mirrorRepo, opts, nil)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"net/http"
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +65,7 @@ func testMirrorPush(t *testing.T, u *url.URL) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	assert.Len(t, mirrors, 2)
 | 
			
		||||
 | 
			
		||||
	ok := mirror_service.SyncPushMirror(context.Background(), mirrors[0].ID)
 | 
			
		||||
	ok := mirror_service.SyncPushMirror(t.Context(), mirrors[0].ID)
 | 
			
		||||
	assert.True(t, ok)
 | 
			
		||||
 | 
			
		||||
	srcGitRepo, err := gitrepo.OpenRepository(git.DefaultContext, srcRepo)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package integration
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"crypto/sha256"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
| 
						 | 
				
			
			@ -518,7 +517,7 @@ func TestSignInOAuthCallbackSignIn(t *testing.T) {
 | 
			
		|||
		LoginSource: gitlab.ID,
 | 
			
		||||
		LoginName:   userGitLabUserID,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, userGitLab)()
 | 
			
		||||
	defer createUser(t.Context(), t, userGitLab)()
 | 
			
		||||
 | 
			
		||||
	//
 | 
			
		||||
	// A request for user information sent to Goth will return a
 | 
			
		||||
| 
						 | 
				
			
			@ -556,7 +555,7 @@ func TestSignInOAuthCallbackWithoutPKCEWhenUnsupported(t *testing.T) {
 | 
			
		|||
		LoginSource: gitlab.ID,
 | 
			
		||||
		LoginName:   userGitLabUserID,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, userGitLab)()
 | 
			
		||||
	defer createUser(t.Context(), t, userGitLab)()
 | 
			
		||||
 | 
			
		||||
	// initial redirection (to generate the code_challenge)
 | 
			
		||||
	session := emptyTestSession(t)
 | 
			
		||||
| 
						 | 
				
			
			@ -598,7 +597,7 @@ func TestSignInOAuthCallbackPKCE(t *testing.T) {
 | 
			
		|||
			LoginSource: authSource.ID,
 | 
			
		||||
			LoginName:   userID,
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, user)()
 | 
			
		||||
		defer createUser(t.Context(), t, user)()
 | 
			
		||||
 | 
			
		||||
		// initial redirection (to generate the code_challenge)
 | 
			
		||||
		session := emptyTestSession(t)
 | 
			
		||||
| 
						 | 
				
			
			@ -656,7 +655,7 @@ func TestSignInOAuthCallbackRedirectToEscaping(t *testing.T) {
 | 
			
		|||
		LoginSource: gitlab.ID,
 | 
			
		||||
		LoginName:   userGitLabUserID,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, userGitLab)()
 | 
			
		||||
	defer createUser(t.Context(), t, userGitLab)()
 | 
			
		||||
 | 
			
		||||
	//
 | 
			
		||||
	// A request for user information sent to Goth will return a
 | 
			
		||||
| 
						 | 
				
			
			@ -731,7 +730,7 @@ func TestSignInOauthCallbackSyncSSHKeys(t *testing.T) {
 | 
			
		|||
		LoginName:   userID,
 | 
			
		||||
		IsActive:    true,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, user)()
 | 
			
		||||
	defer createUser(t.Context(), t, user)()
 | 
			
		||||
 | 
			
		||||
	for _, tt := range []struct {
 | 
			
		||||
		name          string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package integration
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -303,11 +302,11 @@ func TestCantMergeConflict(t *testing.T) {
 | 
			
		|||
		gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo1)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "CONFLICT", false)
 | 
			
		||||
		err = pull.Merge(t.Context(), pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "CONFLICT", false)
 | 
			
		||||
		require.Error(t, err, "Merge should return an error due to conflict")
 | 
			
		||||
		assert.True(t, models.IsErrMergeConflicts(err), "Merge error is not a conflict error")
 | 
			
		||||
 | 
			
		||||
		err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleRebase, "", "CONFLICT", false)
 | 
			
		||||
		err = pull.Merge(t.Context(), pr, user1, gitRepo, repo_model.MergeStyleRebase, "", "CONFLICT", false)
 | 
			
		||||
		require.Error(t, err, "Merge should return an error due to conflict")
 | 
			
		||||
		assert.True(t, models.IsErrRebaseConflicts(err), "Merge error is not a conflict error")
 | 
			
		||||
		gitRepo.Close()
 | 
			
		||||
| 
						 | 
				
			
			@ -402,7 +401,7 @@ func TestCantMergeUnrelated(t *testing.T) {
 | 
			
		|||
			BaseBranch: "base",
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "UNRELATED", false)
 | 
			
		||||
		err = pull.Merge(t.Context(), pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "UNRELATED", false)
 | 
			
		||||
		require.Error(t, err, "Merge should return an error due to unrelated")
 | 
			
		||||
		assert.True(t, models.IsErrMergeUnrelatedHistories(err), "Merge error is not a unrelated histories error")
 | 
			
		||||
		gitRepo.Close()
 | 
			
		||||
| 
						 | 
				
			
			@ -442,7 +441,7 @@ func TestFastForwardOnlyMerge(t *testing.T) {
 | 
			
		|||
		gitRepo, err := git.OpenRepository(git.DefaultContext, repo_model.RepoPath(user1.Name, repo1.Name))
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleFastForwardOnly, "", "FAST-FORWARD-ONLY", false)
 | 
			
		||||
		err = pull.Merge(t.Context(), pr, user1, gitRepo, repo_model.MergeStyleFastForwardOnly, "", "FAST-FORWARD-ONLY", false)
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -484,7 +483,7 @@ func TestCantFastForwardOnlyMergeDiverging(t *testing.T) {
 | 
			
		|||
		gitRepo, err := git.OpenRepository(git.DefaultContext, repo_model.RepoPath(user1.Name, repo1.Name))
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
		err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleFastForwardOnly, "", "DIVERGING", false)
 | 
			
		||||
		err = pull.Merge(t.Context(), pr, user1, gitRepo, repo_model.MergeStyleFastForwardOnly, "", "DIVERGING", false)
 | 
			
		||||
 | 
			
		||||
		require.Error(t, err, "Merge should return an error due to being for a diverging branch")
 | 
			
		||||
		assert.True(t, models.IsErrMergeDivergingFastForwardOnly(err), "Merge error is not a diverging fast-forward-only error")
 | 
			
		||||
| 
						 | 
				
			
			@ -633,7 +632,7 @@ func TestPullMergeIndexerNotifier(t *testing.T) {
 | 
			
		|||
		testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
 | 
			
		||||
		createPullResp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "Indexer notifier test pull")
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, queue.GetManager().FlushAll(context.Background(), 0))
 | 
			
		||||
		require.NoError(t, queue.GetManager().FlushAll(t.Context(), 0))
 | 
			
		||||
		time.Sleep(time.Second)
 | 
			
		||||
 | 
			
		||||
		repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
 | 
			
		||||
| 
						 | 
				
			
			@ -672,7 +671,7 @@ func TestPullMergeIndexerNotifier(t *testing.T) {
 | 
			
		|||
		})
 | 
			
		||||
		assert.True(t, issue.IsClosed)
 | 
			
		||||
 | 
			
		||||
		require.NoError(t, queue.GetManager().FlushAll(context.Background(), 0))
 | 
			
		||||
		require.NoError(t, queue.GetManager().FlushAll(t.Context(), 0))
 | 
			
		||||
		time.Sleep(time.Second)
 | 
			
		||||
 | 
			
		||||
		// search issues again
 | 
			
		||||
| 
						 | 
				
			
			@ -692,7 +691,7 @@ func testResetRepo(t *testing.T, repoPath, branch, commitID string) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
	f.Close()
 | 
			
		||||
 | 
			
		||||
	repo, err := git.OpenRepository(context.Background(), repoPath)
 | 
			
		||||
	repo, err := git.OpenRepository(t.Context(), repoPath)
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	defer repo.Close()
 | 
			
		||||
	id, err := repo.GetBranchCommitID(branch)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +99,7 @@ func TestPullRequestSynchronized(t *testing.T) {
 | 
			
		|||
			logChecker.Filter("Updating PR").StopMark("TestPullRequest ")
 | 
			
		||||
			defer cleanup()
 | 
			
		||||
 | 
			
		||||
			pull_service.TestPullRequest(context.Background(), owner, repo.ID, testCase.olderThan, "branch2", true, pull.HeadCommitID, pull.HeadCommitID)
 | 
			
		||||
			pull_service.TestPullRequest(t.Context(), owner, repo.ID, testCase.olderThan, "branch2", true, pull.HeadCommitID, pull.HeadCommitID)
 | 
			
		||||
			logFiltered, logStopped := logChecker.Check(5 * time.Second)
 | 
			
		||||
			assert.True(t, logStopped)
 | 
			
		||||
			assert.Equal(t, testCase.expected, logFiltered[0])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
| 
						 | 
				
			
			@ -179,7 +178,7 @@ func TestPullView_ResolveInvalidatedReviewComment(t *testing.T) {
 | 
			
		|||
		// (to invalidate it properly, one should push a commit which should trigger this logic,
 | 
			
		||||
		// in the meantime, use this quick-and-dirty trick)
 | 
			
		||||
		comment := loadComment(t, commentID)
 | 
			
		||||
		require.NoError(t, issues_model.UpdateCommentInvalidate(context.Background(), &issues_model.Comment{
 | 
			
		||||
		require.NoError(t, issues_model.UpdateCommentInvalidate(t.Context(), &issues_model.Comment{
 | 
			
		||||
			ID:          comment.ID,
 | 
			
		||||
			Invalidated: true,
 | 
			
		||||
		}))
 | 
			
		||||
| 
						 | 
				
			
			@ -241,7 +240,7 @@ func TestPullView_ResolveInvalidatedReviewComment(t *testing.T) {
 | 
			
		|||
			// (to invalidate it properly, one should push a commit which should trigger this logic,
 | 
			
		||||
			// in the meantime, use this quick-and-dirty trick)
 | 
			
		||||
			comment := loadComment(t, commentID)
 | 
			
		||||
			require.NoError(t, issues_model.UpdateCommentInvalidate(context.Background(), &issues_model.Comment{
 | 
			
		||||
			require.NoError(t, issues_model.UpdateCommentInvalidate(t.Context(), &issues_model.Comment{
 | 
			
		||||
				ID:          comment.ID,
 | 
			
		||||
				Invalidated: true,
 | 
			
		||||
			}))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"testing"
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +47,7 @@ func TestRemote_MaybePromoteUserSuccess(t *testing.T) {
 | 
			
		|||
		LoginSource: remote.ID,
 | 
			
		||||
		LoginName:   gitlabUserID,
 | 
			
		||||
	}
 | 
			
		||||
	defer createUser(context.Background(), t, userBeforeSignIn)()
 | 
			
		||||
	defer createUser(t.Context(), t, userBeforeSignIn)()
 | 
			
		||||
 | 
			
		||||
	//
 | 
			
		||||
	// A request for user information sent to Goth will return a
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +80,7 @@ func TestRemote_MaybePromoteUserSuccess(t *testing.T) {
 | 
			
		|||
func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		||||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx := t.Context()
 | 
			
		||||
	//
 | 
			
		||||
	// OAuth2 authentication source GitLab
 | 
			
		||||
	//
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +125,7 @@ func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		|||
			LoginName:   remoteUserID,
 | 
			
		||||
			Email:       "some@example.com",
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, remoteUser)()
 | 
			
		||||
		defer createUser(t.Context(), t, remoteUser)()
 | 
			
		||||
		promoted, reason, err := remote_service.MaybePromoteRemoteUser(ctx, gitlabSource, remoteUserID, "")
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.False(t, promoted)
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +142,7 @@ func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		|||
			LoginSource: nonexistentloginsource,
 | 
			
		||||
			LoginName:   remoteUserID,
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, remoteUser)()
 | 
			
		||||
		defer createUser(t.Context(), t, remoteUser)()
 | 
			
		||||
		promoted, reason, err := remote_service.MaybePromoteRemoteUser(ctx, gitlabSource, remoteUserID, "")
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.False(t, promoted)
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +158,7 @@ func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		|||
			LoginSource: gitlabSource.ID,
 | 
			
		||||
			LoginName:   remoteUserID,
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, remoteUser)()
 | 
			
		||||
		defer createUser(t.Context(), t, remoteUser)()
 | 
			
		||||
		promoted, reason, err := remote_service.MaybePromoteRemoteUser(ctx, gitlabSource, remoteUserID, "")
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.False(t, promoted)
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +179,7 @@ func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		|||
			LoginSource: remoteSource.ID,
 | 
			
		||||
			LoginName:   remoteUserID,
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, remoteUser)()
 | 
			
		||||
		defer createUser(t.Context(), t, remoteUser)()
 | 
			
		||||
		promoted, reason, err := remote_service.MaybePromoteRemoteUser(ctx, unrelatedSource, remoteUserID, remoteEmail)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.False(t, promoted)
 | 
			
		||||
| 
						 | 
				
			
			@ -197,7 +196,7 @@ func TestRemote_MaybePromoteUserFail(t *testing.T) {
 | 
			
		|||
			LoginSource: remoteSource.ID,
 | 
			
		||||
			LoginName:   remoteUserID,
 | 
			
		||||
		}
 | 
			
		||||
		defer createUser(context.Background(), t, remoteUser)()
 | 
			
		||||
		defer createUser(t.Context(), t, remoteUser)()
 | 
			
		||||
		promoted, reason, err := remote_service.MaybePromoteRemoteUser(ctx, gitlabSource, remoteUserID, remoteEmail)
 | 
			
		||||
		require.NoError(t, err)
 | 
			
		||||
		assert.True(t, promoted)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +41,7 @@ func TestRepoCloneWiki(t *testing.T) {
 | 
			
		|||
		u, _ = url.Parse(r)
 | 
			
		||||
		u.User = url.UserPassword("user2", userPassword)
 | 
			
		||||
		t.Run("Clone", func(t *testing.T) {
 | 
			
		||||
			require.NoError(t, git.CloneWithArgs(context.Background(), git.AllowLFSFiltersArgs(), u.String(), dstPath, git.CloneRepoOptions{}))
 | 
			
		||||
			require.NoError(t, git.CloneWithArgs(t.Context(), git.AllowLFSFiltersArgs(), u.String(), dstPath, git.CloneRepoOptions{}))
 | 
			
		||||
			assertFileEqual(t, filepath.Join(dstPath, "Home.md"), []byte("# Home page\n\nThis is the home page!\n"))
 | 
			
		||||
			assertFileExist(t, filepath.Join(dstPath, "Page-With-Image.md"))
 | 
			
		||||
			assertFileExist(t, filepath.Join(dstPath, "Page-With-Spaced-Name.md"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -267,9 +267,7 @@ func cancelProcesses(t testing.TB, delay time.Duration) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func PrepareGitRepoDirectory(t testing.TB) {
 | 
			
		||||
	var err error
 | 
			
		||||
	setting.RepoRootPath, err = os.MkdirTemp(t.TempDir(), "forgejo-repo-rooth")
 | 
			
		||||
	require.NoError(t, err)
 | 
			
		||||
	setting.RepoRootPath = t.TempDir()
 | 
			
		||||
	require.NoError(t, unittest.CopyDir(preparedDir, setting.RepoRootPath))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue