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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue