@@ -127,211 +127,6 @@ func TestPushCommits_AvatarLink(t *testing.T) {
127127 pushCommits .
AvatarLink (
"[email protected] " ))
128128}
129129
130- func TestUpdateIssuesCommit (t * testing.T ) {
131- assert .NoError (t , PrepareTestDatabase ())
132- pushCommits := []* PushCommit {
133- {
134- Sha1 : "abcdef1" ,
135- CommitterEmail :
"[email protected] " ,
136- CommitterName : "User Two" ,
137- 138- AuthorName : "User Four" ,
139- Message : "start working on #FST-1, #1" ,
140- },
141- {
142- Sha1 : "abcdef2" ,
143- CommitterEmail :
"[email protected] " ,
144- CommitterName : "User Two" ,
145- 146- AuthorName : "User Two" ,
147- Message : "a plain message" ,
148- },
149- {
150- Sha1 : "abcdef2" ,
151- CommitterEmail :
"[email protected] " ,
152- CommitterName : "User Two" ,
153- 154- AuthorName : "User Two" ,
155- Message : "close #2" ,
156- },
157- }
158-
159- user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
160- repo := AssertExistsAndLoadBean (t , & Repository {ID : 1 }).(* Repository )
161- repo .Owner = user
162-
163- commentBean := & Comment {
164- Type : CommentTypeCommitRef ,
165- CommitSHA : "abcdef1" ,
166- PosterID : user .ID ,
167- IssueID : 1 ,
168- }
169- issueBean := & Issue {RepoID : repo .ID , Index : 4 }
170-
171- AssertNotExistsBean (t , commentBean )
172- AssertNotExistsBean (t , & Issue {RepoID : repo .ID , Index : 2 }, "is_closed=1" )
173- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , repo .DefaultBranch ))
174- AssertExistsAndLoadBean (t , commentBean )
175- AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
176- CheckConsistencyFor (t , & Action {})
177-
178- // Test that push to a non-default branch closes no issue.
179- pushCommits = []* PushCommit {
180- {
181- Sha1 : "abcdef1" ,
182- CommitterEmail :
"[email protected] " ,
183- CommitterName : "User Two" ,
184- 185- AuthorName : "User Four" ,
186- Message : "close #1" ,
187- },
188- }
189- repo = AssertExistsAndLoadBean (t , & Repository {ID : 3 }).(* Repository )
190- commentBean = & Comment {
191- Type : CommentTypeCommitRef ,
192- CommitSHA : "abcdef1" ,
193- PosterID : user .ID ,
194- IssueID : 6 ,
195- }
196- issueBean = & Issue {RepoID : repo .ID , Index : 1 }
197-
198- AssertNotExistsBean (t , commentBean )
199- AssertNotExistsBean (t , & Issue {RepoID : repo .ID , Index : 1 }, "is_closed=1" )
200- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , "non-existing-branch" ))
201- AssertExistsAndLoadBean (t , commentBean )
202- AssertNotExistsBean (t , issueBean , "is_closed=1" )
203- CheckConsistencyFor (t , & Action {})
204- }
205-
206- func TestUpdateIssuesCommit_Colon (t * testing.T ) {
207- assert .NoError (t , PrepareTestDatabase ())
208- pushCommits := []* PushCommit {
209- {
210- Sha1 : "abcdef2" ,
211- CommitterEmail :
"[email protected] " ,
212- CommitterName : "User Two" ,
213- 214- AuthorName : "User Two" ,
215- Message : "close: #2" ,
216- },
217- }
218-
219- user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
220- repo := AssertExistsAndLoadBean (t , & Repository {ID : 1 }).(* Repository )
221- repo .Owner = user
222-
223- issueBean := & Issue {RepoID : repo .ID , Index : 4 }
224-
225- AssertNotExistsBean (t , & Issue {RepoID : repo .ID , Index : 2 }, "is_closed=1" )
226- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , repo .DefaultBranch ))
227- AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
228- CheckConsistencyFor (t , & Action {})
229- }
230-
231- func TestUpdateIssuesCommit_Issue5957 (t * testing.T ) {
232- assert .NoError (t , PrepareTestDatabase ())
233- user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
234-
235- // Test that push to a non-default branch closes an issue.
236- pushCommits := []* PushCommit {
237- {
238- Sha1 : "abcdef1" ,
239- CommitterEmail :
"[email protected] " ,
240- CommitterName : "User Two" ,
241- 242- AuthorName : "User Four" ,
243- Message : "close #2" ,
244- },
245- }
246-
247- repo := AssertExistsAndLoadBean (t , & Repository {ID : 2 }).(* Repository )
248- commentBean := & Comment {
249- Type : CommentTypeCommitRef ,
250- CommitSHA : "abcdef1" ,
251- PosterID : user .ID ,
252- IssueID : 7 ,
253- }
254-
255- issueBean := & Issue {RepoID : repo .ID , Index : 2 , ID : 7 }
256-
257- AssertNotExistsBean (t , commentBean )
258- AssertNotExistsBean (t , issueBean , "is_closed=1" )
259- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , "non-existing-branch" ))
260- AssertExistsAndLoadBean (t , commentBean )
261- AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
262- CheckConsistencyFor (t , & Action {})
263- }
264-
265- func TestUpdateIssuesCommit_AnotherRepo (t * testing.T ) {
266- assert .NoError (t , PrepareTestDatabase ())
267- user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
268-
269- // Test that a push to default branch closes issue in another repo
270- // If the user also has push permissions to that repo
271- pushCommits := []* PushCommit {
272- {
273- Sha1 : "abcdef1" ,
274- CommitterEmail :
"[email protected] " ,
275- CommitterName : "User Two" ,
276- 277- AuthorName : "User Two" ,
278- Message : "close user2/repo1#1" ,
279- },
280- }
281-
282- repo := AssertExistsAndLoadBean (t , & Repository {ID : 2 }).(* Repository )
283- commentBean := & Comment {
284- Type : CommentTypeCommitRef ,
285- CommitSHA : "abcdef1" ,
286- PosterID : user .ID ,
287- IssueID : 1 ,
288- }
289-
290- issueBean := & Issue {RepoID : 1 , Index : 1 , ID : 1 }
291-
292- AssertNotExistsBean (t , commentBean )
293- AssertNotExistsBean (t , issueBean , "is_closed=1" )
294- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , repo .DefaultBranch ))
295- AssertExistsAndLoadBean (t , commentBean )
296- AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
297- CheckConsistencyFor (t , & Action {})
298- }
299-
300- func TestUpdateIssuesCommit_AnotherRepoNoPermission (t * testing.T ) {
301- assert .NoError (t , PrepareTestDatabase ())
302- user := AssertExistsAndLoadBean (t , & User {ID : 10 }).(* User )
303-
304- // Test that a push with close reference *can not* close issue
305- // If the commiter doesn't have push rights in that repo
306- pushCommits := []* PushCommit {
307- {
308- Sha1 : "abcdef3" ,
309- CommitterEmail :
"[email protected] " ,
310- CommitterName : "User Ten" ,
311- 312- AuthorName : "User Ten" ,
313- Message : "close user3/repo3#1" ,
314- },
315- }
316-
317- repo := AssertExistsAndLoadBean (t , & Repository {ID : 6 }).(* Repository )
318- commentBean := & Comment {
319- Type : CommentTypeCommitRef ,
320- CommitSHA : "abcdef3" ,
321- PosterID : user .ID ,
322- IssueID : 6 ,
323- }
324-
325- issueBean := & Issue {RepoID : 3 , Index : 1 , ID : 6 }
326-
327- AssertNotExistsBean (t , commentBean )
328- AssertNotExistsBean (t , issueBean , "is_closed=1" )
329- assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits , repo .DefaultBranch ))
330- AssertNotExistsBean (t , commentBean )
331- AssertNotExistsBean (t , issueBean , "is_closed=1" )
332- CheckConsistencyFor (t , & Action {})
333- }
334-
335130func TestGetFeeds (t * testing.T ) {
336131 // test with an individual user
337132 assert .NoError (t , PrepareTestDatabase ())
0 commit comments