summaryrefslogtreecommitdiffstats
path: root/models/issues/content_history_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /models/issues/content_history_test.go
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
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
Diffstat (limited to 'models/issues/content_history_test.go')
-rw-r--r--models/issues/content_history_test.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/models/issues/content_history_test.go b/models/issues/content_history_test.go
index 71ccc6e6a7..3cbc0ad5e0 100644
--- a/models/issues/content_history_test.go
+++ b/models/issues/content_history_test.go
@@ -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)