mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
This commit is contained in:
parent
d81e31ad78
commit
fd7d83ace6
232 changed files with 1463 additions and 2108 deletions
|
@ -18,18 +18,17 @@ func TestContentHistory(t *testing.T) {
|
|||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
dbCtx := db.DefaultContext
|
||||
dbEngine := db.GetEngine(dbCtx)
|
||||
timeStampNow := timeutil.TimeStampNow()
|
||||
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 0, timeStampNow, "i-a", true)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 0, timeStampNow.Add(2), "i-b", false)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 0, timeStampNow.Add(7), "i-c", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 0, timeStampNow, "i-a", true)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 0, timeStampNow.Add(2), "i-b", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 0, timeStampNow.Add(7), "i-c", false)
|
||||
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 100, timeStampNow, "c-a", true)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 100, timeStampNow.Add(5), "c-b", false)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 100, timeStampNow.Add(20), "c-c", false)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 100, timeStampNow.Add(50), "c-d", false)
|
||||
_ = SaveIssueContentHistory(dbEngine, 1, 10, 100, timeStampNow.Add(51), "c-e", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 100, timeStampNow, "c-a", true)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 100, timeStampNow.Add(5), "c-b", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 100, timeStampNow.Add(20), "c-c", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 100, timeStampNow.Add(50), "c-d", false)
|
||||
_ = SaveIssueContentHistory(dbCtx, 1, 10, 100, timeStampNow.Add(51), "c-e", false)
|
||||
|
||||
h1, _ := GetIssueContentHistoryByID(dbCtx, 1)
|
||||
assert.EqualValues(t, 1, h1.ID)
|
||||
|
@ -47,7 +46,7 @@ func TestContentHistory(t *testing.T) {
|
|||
Name string
|
||||
FullName string
|
||||
}
|
||||
_ = dbEngine.Sync2(&User{})
|
||||
_ = db.GetEngine(dbCtx).Sync2(&User{})
|
||||
|
||||
list1, _ := FetchIssueContentHistoryList(dbCtx, 10, 0)
|
||||
assert.Len(t, list1, 3)
|
||||
|
@ -70,7 +69,7 @@ func TestContentHistory(t *testing.T) {
|
|||
assert.EqualValues(t, 4, h6Prev.ID)
|
||||
|
||||
// only keep 3 history revisions for comment_id=100, the first and the last should never be deleted
|
||||
keepLimitedContentHistory(dbEngine, 10, 100, 3)
|
||||
keepLimitedContentHistory(dbCtx, 10, 100, 3)
|
||||
list1, _ = FetchIssueContentHistoryList(dbCtx, 10, 0)
|
||||
assert.Len(t, list1, 3)
|
||||
list2, _ = FetchIssueContentHistoryList(dbCtx, 10, 100)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue