mirror of
https://github.com/go-gitea/gitea
synced 2025-09-17 14:18:15 +00:00
Remove incorrect "db.DefaultContext" usages (#35366)
This commit is contained in:
@@ -162,7 +162,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
||||
func Test_loadIsRefDeleted(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
runs, total, err := db.FindAndCount[actions_model.ActionRun](db.DefaultContext,
|
||||
runs, total, err := db.FindAndCount[actions_model.ActionRun](t.Context(),
|
||||
actions_model.FindRunOptions{RepoID: 4, Ref: "refs/heads/test"})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, runs, 1)
|
||||
@@ -171,7 +171,7 @@ func Test_loadIsRefDeleted(t *testing.T) {
|
||||
assert.False(t, run.IsRefDeleted)
|
||||
}
|
||||
|
||||
assert.NoError(t, loadIsRefDeleted(db.DefaultContext, 4, runs))
|
||||
assert.NoError(t, loadIsRefDeleted(t.Context(), 4, runs))
|
||||
for _, run := range runs {
|
||||
assert.True(t, run.IsRefDeleted)
|
||||
}
|
||||
|
@@ -23,10 +23,10 @@ import (
|
||||
func TestRenderConversation(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
pr, _ := issues_model.GetPullRequestByID(db.DefaultContext, 2)
|
||||
_ = pr.LoadIssue(db.DefaultContext)
|
||||
_ = pr.Issue.LoadPoster(db.DefaultContext)
|
||||
_ = pr.Issue.LoadRepo(db.DefaultContext)
|
||||
pr, _ := issues_model.GetPullRequestByID(t.Context(), 2)
|
||||
_ = pr.LoadIssue(t.Context())
|
||||
_ = pr.Issue.LoadPoster(t.Context())
|
||||
_ = pr.Issue.LoadRepo(t.Context())
|
||||
|
||||
run := func(name string, cb func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder)) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
@@ -73,7 +73,7 @@ func TestRenderConversation(t *testing.T) {
|
||||
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
|
||||
})
|
||||
run("diff non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||
err := db.TruncateBeans(db.DefaultContext, &issues_model.Review{})
|
||||
err := db.TruncateBeans(t.Context(), &issues_model.Review{})
|
||||
assert.NoError(t, err)
|
||||
ctx.Data["ShowOutdatedComments"] = true
|
||||
renderConversation(ctx, preparedComment, "diff")
|
||||
@@ -81,7 +81,7 @@ func TestRenderConversation(t *testing.T) {
|
||||
assert.NotContains(t, resp.Body.String(), `status-page-500`)
|
||||
})
|
||||
run("timeline non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||
err := db.TruncateBeans(db.DefaultContext, &issues_model.Review{})
|
||||
err := db.TruncateBeans(t.Context(), &issues_model.Review{})
|
||||
assert.NoError(t, err)
|
||||
ctx.Data["ShowOutdatedComments"] = true
|
||||
renderConversation(ctx, preparedComment, "timeline")
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
@@ -231,7 +230,7 @@ func TestAddTeamPost(t *testing.T) {
|
||||
|
||||
AddTeamPost(ctx)
|
||||
|
||||
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.True(t, repo_service.HasRepository(t.Context(), team, re.ID))
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
||||
assert.Empty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -271,7 +270,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
|
||||
|
||||
AddTeamPost(ctx)
|
||||
|
||||
assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.False(t, repo_service.HasRepository(t.Context(), team, re.ID))
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -312,7 +311,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
||||
AddTeamPost(ctx)
|
||||
|
||||
AddTeamPost(ctx)
|
||||
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.True(t, repo_service.HasRepository(t.Context(), team, re.ID))
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -385,5 +384,5 @@ func TestDeleteTeam(t *testing.T) {
|
||||
|
||||
DeleteTeam(ctx)
|
||||
|
||||
assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.False(t, repo_service.HasRepository(t.Context(), team, re.ID))
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
@@ -242,11 +241,11 @@ func TestDefaultWikiBranch(t *testing.T) {
|
||||
// repo with no wiki
|
||||
repoWithNoWiki := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
|
||||
assert.False(t, repoWithNoWiki.HasWiki())
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(db.DefaultContext, repoWithNoWiki, "main"))
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(t.Context(), repoWithNoWiki, "main"))
|
||||
|
||||
// repo with wiki
|
||||
assert.NoError(t, repo_model.UpdateRepositoryColsNoAutoTime(
|
||||
db.DefaultContext,
|
||||
t.Context(),
|
||||
&repo_model.Repository{ID: 1, DefaultWikiBranch: "wrong-branch"},
|
||||
"default_wiki_branch",
|
||||
),
|
||||
@@ -261,17 +260,17 @@ func TestDefaultWikiBranch(t *testing.T) {
|
||||
assert.Equal(t, "master", ctx.Repo.Repository.DefaultWikiBranch)
|
||||
|
||||
// invalid branch name should fail
|
||||
assert.Error(t, wiki_service.ChangeDefaultWikiBranch(db.DefaultContext, repo, "the bad name"))
|
||||
assert.Error(t, wiki_service.ChangeDefaultWikiBranch(t.Context(), repo, "the bad name"))
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
assert.Equal(t, "master", repo.DefaultWikiBranch)
|
||||
|
||||
// the same branch name, should succeed (actually a no-op)
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(db.DefaultContext, repo, "master"))
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(t.Context(), repo, "master"))
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
assert.Equal(t, "master", repo.DefaultWikiBranch)
|
||||
|
||||
// change to another name
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(db.DefaultContext, repo, "main"))
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(t.Context(), repo, "main"))
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
assert.Equal(t, "main", repo.DefaultWikiBranch)
|
||||
}
|
||||
|
Reference in New Issue
Block a user