aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_xref_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-19 21:39:57 +0800
committerGitHub <noreply@github.com>2021-11-19 21:39:57 +0800
commitfc3d0826096943b979717ed46c9a4cfd86e06106 (patch)
tree3143882ccf4dea3a8bf2a0de9c8da9a4efec26ce /models/issue_xref_test.go
parent7a0347315995b25bcb2dca4786504fb699b5f004 (diff)
downloadgitea-fc3d0826096943b979717ed46c9a4cfd86e06106.tar.gz
gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.zip
Move attachment into models/repo/ (#17650)
* Move attachment into models/repo/ * Fix test * Fix bug
Diffstat (limited to 'models/issue_xref_test.go')
-rw-r--r--models/issue_xref_test.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/models/issue_xref_test.go b/models/issue_xref_test.go
index 551c29dcba..c40e545fa8 100644
--- a/models/issue_xref_test.go
+++ b/models/issue_xref_test.go
@@ -140,19 +140,18 @@ func testCreateIssue(t *testing.T, repo, doer int64, title, content string, ispu
Index: idx,
}
- sess := db.NewSession(db.DefaultContext)
- defer sess.Close()
-
- assert.NoError(t, sess.Begin())
- err = newIssue(sess, d, NewIssueOptions{
+ ctx, committer, err := db.TxContext()
+ assert.NoError(t, err)
+ defer committer.Close()
+ err = newIssue(ctx, d, NewIssueOptions{
Repo: r,
Issue: i,
})
assert.NoError(t, err)
- i, err = getIssueByID(sess, i.ID)
+ i, err = getIssueByID(db.GetEngine(ctx), i.ID)
assert.NoError(t, err)
- assert.NoError(t, i.addCrossReferences(sess, d, false))
- assert.NoError(t, sess.Commit())
+ assert.NoError(t, i.addCrossReferences(ctx, d, false))
+ assert.NoError(t, committer.Commit())
return i
}
@@ -171,12 +170,12 @@ func testCreateComment(t *testing.T, repo, doer, issue int64, content string) *C
i := unittest.AssertExistsAndLoadBean(t, &Issue{ID: issue}).(*Issue)
c := &Comment{Type: CommentTypeComment, PosterID: doer, Poster: d, IssueID: issue, Issue: i, Content: content}
- sess := db.NewSession(db.DefaultContext)
- defer sess.Close()
- assert.NoError(t, sess.Begin())
- _, err := sess.Insert(c)
+ ctx, committer, err := db.TxContext()
+ assert.NoError(t, err)
+ defer committer.Close()
+ err = db.Insert(ctx, c)
assert.NoError(t, err)
- assert.NoError(t, c.addCrossReferences(sess, d, false))
- assert.NoError(t, sess.Commit())
+ assert.NoError(t, c.addCrossReferences(ctx, d, false))
+ assert.NoError(t, committer.Commit())
return c
}