summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-09-29 20:52:39 +0800
committerGitHub <noreply@github.com>2019-09-29 20:52:39 +0800
commitaa9a99cf5f7de47328e5a6ffcba6114294934031 (patch)
treecd5bc73f12a0a8bf7709dccdb18a4b7764563745 /models
parentc6fb7fe27c16c4e43d4d8dbe4d2ff4b3c4c52a29 (diff)
downloadgitea-aa9a99cf5f7de47328e5a6ffcba6114294934031.tar.gz
gitea-aa9a99cf5f7de47328e5a6ffcba6114294934031.zip
Upgrade xorm to latest to fix insert issue bug (#8309)
* upgrade xorm to latest to fix insert issue bug * add newissue unit tests * update xorm version * fix tests
Diffstat (limited to 'models')
-rw-r--r--models/issue_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/models/issue_test.go b/models/issue_test.go
index 1a7e45ae02..317fc7bbc8 100644
--- a/models/issue_test.go
+++ b/models/issue_test.go
@@ -320,3 +320,36 @@ func TestIssue_SearchIssueIDsByKeyword(t *testing.T) {
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{1}, ids)
}
+
+func testInsertIssue(t *testing.T, title, content string) {
+ repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
+ user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+
+ var issue = Issue{
+ RepoID: repo.ID,
+ PosterID: user.ID,
+ Title: title,
+ Content: content,
+ }
+ err := NewIssue(repo, &issue, nil, nil, nil)
+ assert.NoError(t, err)
+
+ var newIssue Issue
+ has, err := x.ID(issue.ID).Get(&newIssue)
+ assert.NoError(t, err)
+ assert.True(t, has)
+ assert.EqualValues(t, issue.Title, newIssue.Title)
+ assert.EqualValues(t, issue.Content, newIssue.Content)
+ // there are 4 issues and max index is 4 on repository 1, so this one should 5
+ assert.EqualValues(t, 5, newIssue.Index)
+
+ _, err = x.ID(issue.ID).Delete(new(Issue))
+ assert.NoError(t, err)
+}
+
+func TestIssue_InsertIssue(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ testInsertIssue(t, "my issue1", "special issue's comments?")
+ testInsertIssue(t, `my issue2, this is my son's love \n \r \ `, "special issue's '' comments?")
+}