Refactor GetNextResourceIndex to make it work properly with transaction (#21469)
Related: * #21362 This PR uses a general and stable method to generate resource index (eg: Issue Index, PR Index) If the code looks good, I can add more tests ps: please skip the diff, only have a look at the new code. It's entirely re-written. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
0647df3e83
commit
6f48a36227
7 changed files with 215 additions and 89 deletions
|
@ -131,7 +131,11 @@ func testCreateIssue(t *testing.T, repo, doer int64, title, content string, ispu
|
|||
r := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repo})
|
||||
d := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: doer})
|
||||
|
||||
idx, err := db.GetNextResourceIndex("issue_index", r.ID)
|
||||
ctx, committer, err := db.TxContext()
|
||||
assert.NoError(t, err)
|
||||
defer committer.Close()
|
||||
|
||||
idx, err := db.GetNextResourceIndex(ctx, "issue_index", r.ID)
|
||||
assert.NoError(t, err)
|
||||
i := &issues_model.Issue{
|
||||
RepoID: r.ID,
|
||||
|
@ -143,9 +147,6 @@ func testCreateIssue(t *testing.T, repo, doer int64, title, content string, ispu
|
|||
Index: idx,
|
||||
}
|
||||
|
||||
ctx, committer, err := db.TxContext()
|
||||
assert.NoError(t, err)
|
||||
defer committer.Close()
|
||||
err = issues_model.NewIssueWithIndex(ctx, d, issues_model.NewIssueOptions{
|
||||
Repo: r,
|
||||
Issue: i,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue