mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-23 02:18:30 +00:00
Remove incorrect "db.DefaultContext" usages (#35366)
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
@@ -140,7 +139,7 @@ func TestAPIGetComment(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
|
||||
assert.NoError(t, comment.LoadIssue(db.DefaultContext))
|
||||
assert.NoError(t, comment.LoadIssue(t.Context()))
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: comment.Issue.RepoID})
|
||||
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||||
|
||||
@@ -154,8 +153,8 @@ func TestAPIGetComment(t *testing.T) {
|
||||
var apiComment api.Comment
|
||||
DecodeJSON(t, resp, &apiComment)
|
||||
|
||||
assert.NoError(t, comment.LoadPoster(db.DefaultContext))
|
||||
expect := convert.ToAPIComment(db.DefaultContext, repo, comment)
|
||||
assert.NoError(t, comment.LoadPoster(t.Context()))
|
||||
expect := convert.ToAPIComment(t.Context(), repo, comment)
|
||||
|
||||
assert.Equal(t, expect.ID, apiComment.ID)
|
||||
assert.Equal(t, expect.Poster.FullName, apiComment.Poster.FullName)
|
||||
@@ -175,7 +174,7 @@ func TestAPIGetSystemUserComment(t *testing.T) {
|
||||
user_model.NewActionsUser(),
|
||||
} {
|
||||
body := "Hello " + systemUser.Name
|
||||
comment, err := issues_model.CreateComment(db.DefaultContext, &issues_model.CreateCommentOptions{
|
||||
comment, err := issues_model.CreateComment(t.Context(), &issues_model.CreateCommentOptions{
|
||||
Type: issues_model.CommentTypeComment,
|
||||
Doer: systemUser,
|
||||
Repo: repo,
|
||||
@@ -192,7 +191,7 @@ func TestAPIGetSystemUserComment(t *testing.T) {
|
||||
|
||||
if assert.NotNil(t, apiComment.Poster) {
|
||||
if assert.Equal(t, systemUser.ID, apiComment.Poster.ID) {
|
||||
assert.NoError(t, comment.LoadPoster(db.DefaultContext))
|
||||
assert.NoError(t, comment.LoadPoster(t.Context()))
|
||||
assert.Equal(t, systemUser.Name, apiComment.Poster.UserName)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user