diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-06-14 10:22:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 10:22:55 +0800 |
commit | 0393a57511dc863bea4783fbb4b57cd11c41688a (patch) | |
tree | f479085c97ffe419e6fe02c88f6a2730a673fcb8 /models/issue_xref_test.go | |
parent | a005265718b840d34858a3b705f8133e1b4dbdbf (diff) | |
download | gitea-0393a57511dc863bea4783fbb4b57cd11c41688a.tar.gz gitea-0393a57511dc863bea4783fbb4b57cd11c41688a.zip |
Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599)
* Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index
* Fix pull index
* Add tests for concurrent creating issues
* Fix lint
* Fix tests
* Fix postgres test
* Add test for migration v180
* Rename wrong test file name
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/issue_xref_test.go')
-rw-r--r-- | models/issue_xref_test.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/models/issue_xref_test.go b/models/issue_xref_test.go index f7a1adb083..a2d1a4b11e 100644 --- a/models/issue_xref_test.go +++ b/models/issue_xref_test.go @@ -125,12 +125,27 @@ func TestXRef_ResolveCrossReferences(t *testing.T) { func testCreateIssue(t *testing.T, repo, doer int64, title, content string, ispull bool) *Issue { r := AssertExistsAndLoadBean(t, &Repository{ID: repo}).(*Repository) d := AssertExistsAndLoadBean(t, &User{ID: doer}).(*User) - i := &Issue{RepoID: r.ID, PosterID: d.ID, Poster: d, Title: title, Content: content, IsPull: ispull} + + idx, err := GetNextResourceIndex("issue_index", r.ID) + assert.NoError(t, err) + i := &Issue{ + RepoID: r.ID, + PosterID: d.ID, + Poster: d, + Title: title, + Content: content, + IsPull: ispull, + Index: idx, + } sess := x.NewSession() defer sess.Close() + assert.NoError(t, sess.Begin()) - _, err := sess.SetExpr("`index`", "coalesce(MAX(`index`),0)+1").Where("repo_id=?", repo).Insert(i) + err = newIssue(sess, d, NewIssueOptions{ + Repo: r, + Issue: i, + }) assert.NoError(t, err) i, err = getIssueByID(sess, i.ID) assert.NoError(t, err) |