@@ -10,7 +10,7 @@ import (
10
10
"net/url"
11
11
"testing"
12
12
13
- "code.gitea.io/gitea/models"
13
+ issues_model "code.gitea.io/gitea/models/issues "
14
14
repo_model "code.gitea.io/gitea/models/repo"
15
15
"code.gitea.io/gitea/models/unittest"
16
16
user_model "code.gitea.io/gitea/models/user"
@@ -23,9 +23,9 @@ import (
23
23
func TestAPIListRepoComments (t * testing.T ) {
24
24
defer prepareTestEnv (t )()
25
25
26
- comment := unittest .AssertExistsAndLoadBean (t , & models .Comment {},
27
- unittest .Cond ("type = ?" , models .CommentTypeComment )).(* models .Comment )
28
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : comment .IssueID }).(* models .Issue )
26
+ comment := unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {},
27
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment )).(* issues_model .Comment )
28
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : comment .IssueID }).(* issues_model .Issue )
29
29
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
30
30
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
31
31
@@ -38,10 +38,10 @@ func TestAPIListRepoComments(t *testing.T) {
38
38
DecodeJSON (t , resp , & apiComments )
39
39
assert .Len (t , apiComments , 2 )
40
40
for _ , apiComment := range apiComments {
41
- c := & models .Comment {ID : apiComment .ID }
41
+ c := & issues_model .Comment {ID : apiComment .ID }
42
42
unittest .AssertExistsAndLoadBean (t , c ,
43
- unittest .Cond ("type = ?" , models .CommentTypeComment ))
44
- unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : c .IssueID , RepoID : repo .ID })
43
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment ))
44
+ unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : c .IssueID , RepoID : repo .ID })
45
45
}
46
46
47
47
// test before and since filters
@@ -69,9 +69,9 @@ func TestAPIListRepoComments(t *testing.T) {
69
69
func TestAPIListIssueComments (t * testing.T ) {
70
70
defer prepareTestEnv (t )()
71
71
72
- comment := unittest .AssertExistsAndLoadBean (t , & models .Comment {},
73
- unittest .Cond ("type = ?" , models .CommentTypeComment )).(* models .Comment )
74
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : comment .IssueID }).(* models .Issue )
72
+ comment := unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {},
73
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment )).(* issues_model .Comment )
74
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : comment .IssueID }).(* issues_model .Issue )
75
75
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
76
76
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
77
77
@@ -82,16 +82,16 @@ func TestAPIListIssueComments(t *testing.T) {
82
82
83
83
var comments []* api.Comment
84
84
DecodeJSON (t , resp , & comments )
85
- expectedCount := unittest .GetCount (t , & models .Comment {IssueID : issue .ID },
86
- unittest .Cond ("type = ?" , models .CommentTypeComment ))
85
+ expectedCount := unittest .GetCount (t , & issues_model .Comment {IssueID : issue .ID },
86
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment ))
87
87
assert .EqualValues (t , expectedCount , len (comments ))
88
88
}
89
89
90
90
func TestAPICreateComment (t * testing.T ) {
91
91
defer prepareTestEnv (t )()
92
92
const commentBody = "Comment body"
93
93
94
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {}).(* models .Issue )
94
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {}).(* issues_model .Issue )
95
95
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
96
96
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
97
97
@@ -107,13 +107,13 @@ func TestAPICreateComment(t *testing.T) {
107
107
var updatedComment api.Comment
108
108
DecodeJSON (t , resp , & updatedComment )
109
109
assert .EqualValues (t , commentBody , updatedComment .Body )
110
- unittest .AssertExistsAndLoadBean (t , & models .Comment {ID : updatedComment .ID , IssueID : issue .ID , Content : commentBody })
110
+ unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {ID : updatedComment .ID , IssueID : issue .ID , Content : commentBody })
111
111
}
112
112
113
113
func TestAPIGetComment (t * testing.T ) {
114
114
defer prepareTestEnv (t )()
115
115
116
- comment := unittest .AssertExistsAndLoadBean (t , & models .Comment {ID : 2 }).(* models .Comment )
116
+ comment := unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {ID : 2 }).(* issues_model .Comment )
117
117
assert .NoError (t , comment .LoadIssue ())
118
118
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : comment .Issue .RepoID }).(* repo_model.Repository )
119
119
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
@@ -141,9 +141,9 @@ func TestAPIEditComment(t *testing.T) {
141
141
defer prepareTestEnv (t )()
142
142
const newCommentBody = "This is the new comment body"
143
143
144
- comment := unittest .AssertExistsAndLoadBean (t , & models .Comment {},
145
- unittest .Cond ("type = ?" , models .CommentTypeComment )).(* models .Comment )
146
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : comment .IssueID }).(* models .Issue )
144
+ comment := unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {},
145
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment )).(* issues_model .Comment )
146
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : comment .IssueID }).(* issues_model .Issue )
147
147
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
148
148
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
149
149
@@ -160,15 +160,15 @@ func TestAPIEditComment(t *testing.T) {
160
160
DecodeJSON (t , resp , & updatedComment )
161
161
assert .EqualValues (t , comment .ID , updatedComment .ID )
162
162
assert .EqualValues (t , newCommentBody , updatedComment .Body )
163
- unittest .AssertExistsAndLoadBean (t , & models .Comment {ID : comment .ID , IssueID : issue .ID , Content : newCommentBody })
163
+ unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {ID : comment .ID , IssueID : issue .ID , Content : newCommentBody })
164
164
}
165
165
166
166
func TestAPIDeleteComment (t * testing.T ) {
167
167
defer prepareTestEnv (t )()
168
168
169
- comment := unittest .AssertExistsAndLoadBean (t , & models .Comment {},
170
- unittest .Cond ("type = ?" , models .CommentTypeComment )).(* models .Comment )
171
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : comment .IssueID }).(* models .Issue )
169
+ comment := unittest .AssertExistsAndLoadBean (t , & issues_model .Comment {},
170
+ unittest .Cond ("type = ?" , issues_model .CommentTypeComment )).(* issues_model .Comment )
171
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : comment .IssueID }).(* issues_model .Issue )
172
172
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
173
173
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
174
174
@@ -178,14 +178,14 @@ func TestAPIDeleteComment(t *testing.T) {
178
178
repoOwner .Name , repo .Name , comment .ID , token )
179
179
session .MakeRequest (t , req , http .StatusNoContent )
180
180
181
- unittest .AssertNotExistsBean (t , & models .Comment {ID : comment .ID })
181
+ unittest .AssertNotExistsBean (t , & issues_model .Comment {ID : comment .ID })
182
182
}
183
183
184
184
func TestAPIListIssueTimeline (t * testing.T ) {
185
185
defer prepareTestEnv (t )()
186
186
187
187
// load comment
188
- issue := unittest .AssertExistsAndLoadBean (t , & models .Issue {ID : 1 }).(* models .Issue )
188
+ issue := unittest .AssertExistsAndLoadBean (t , & issues_model .Issue {ID : 1 }).(* issues_model .Issue )
189
189
repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : issue .RepoID }).(* repo_model.Repository )
190
190
repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID }).(* user_model.User )
191
191
@@ -199,6 +199,6 @@ func TestAPIListIssueTimeline(t *testing.T) {
199
199
// lists extracted directly from DB are the same
200
200
var comments []* api.TimelineComment
201
201
DecodeJSON (t , resp , & comments )
202
- expectedCount := unittest .GetCount (t , & models .Comment {IssueID : issue .ID })
202
+ expectedCount := unittest .GetCount (t , & issues_model .Comment {IssueID : issue .ID })
203
203
assert .EqualValues (t , expectedCount , len (comments ))
204
204
}
0 commit comments