forked from forgejo/forgejo
Propagate context and ensure git commands run in request context (#17868)
This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
4563148a61
commit
5cb0c9aa0d
193 changed files with 1264 additions and 1154 deletions
|
@ -7,6 +7,7 @@ package models
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
|
||||
|
@ -28,23 +29,23 @@ func TestGetReviewByID(t *testing.T) {
|
|||
func TestReview_LoadAttributes(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
review := unittest.AssertExistsAndLoadBean(t, &Review{ID: 1}).(*Review)
|
||||
assert.NoError(t, review.LoadAttributes())
|
||||
assert.NoError(t, review.LoadAttributes(db.DefaultContext))
|
||||
assert.NotNil(t, review.Issue)
|
||||
assert.NotNil(t, review.Reviewer)
|
||||
|
||||
invalidReview1 := unittest.AssertExistsAndLoadBean(t, &Review{ID: 2}).(*Review)
|
||||
assert.Error(t, invalidReview1.LoadAttributes())
|
||||
assert.Error(t, invalidReview1.LoadAttributes(db.DefaultContext))
|
||||
|
||||
invalidReview2 := unittest.AssertExistsAndLoadBean(t, &Review{ID: 3}).(*Review)
|
||||
assert.Error(t, invalidReview2.LoadAttributes())
|
||||
assert.Error(t, invalidReview2.LoadAttributes(db.DefaultContext))
|
||||
}
|
||||
|
||||
func TestReview_LoadCodeComments(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
review := unittest.AssertExistsAndLoadBean(t, &Review{ID: 4}).(*Review)
|
||||
assert.NoError(t, review.LoadAttributes())
|
||||
assert.NoError(t, review.LoadCodeComments())
|
||||
assert.NoError(t, review.LoadAttributes(db.DefaultContext))
|
||||
assert.NoError(t, review.LoadCodeComments(db.DefaultContext))
|
||||
assert.Len(t, review.CodeComments, 1)
|
||||
assert.Equal(t, int64(4), review.CodeComments["README.md"][int64(4)][0].Line)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue