|
5 | 5 | "path"
|
6 | 6 | "testing"
|
7 | 7 |
|
8 |
| - "code.gitea.io/git" |
9 |
| - "code.gitea.io/gitea/modules/notification" |
10 | 8 | "code.gitea.io/gitea/modules/setting"
|
11 | 9 |
|
12 | 10 | "github.com/stretchr/testify/assert"
|
@@ -242,121 +240,6 @@ func TestUpdateIssuesCommit_Issue5957(t *testing.T) {
|
242 | 240 | CheckConsistencyFor(t, &Action{})
|
243 | 241 | }
|
244 | 242 |
|
245 |
| -func testCorrectRepoAction(t *testing.T, opts CommitRepoActionOptions, actionBean *Action) { |
246 |
| - AssertNotExistsBean(t, actionBean) |
247 |
| - evt, err := CommitRepoAction(opts) |
248 |
| - notification.NotifyCommitsPushed(evt.Pusher, evt.OpType, evt.Repo, evt.RefName, evt.Data) |
249 |
| - assert.NoError(t, err) |
250 |
| - AssertExistsAndLoadBean(t, actionBean) |
251 |
| - CheckConsistencyFor(t, &Action{}) |
252 |
| -} |
253 |
| - |
254 |
| -func TestCommitRepoAction(t *testing.T) { |
255 |
| - samples := []struct { |
256 |
| - userID int64 |
257 |
| - repositoryID int64 |
258 |
| - commitRepoActionOptions CommitRepoActionOptions |
259 |
| - action Action |
260 |
| - }{ |
261 |
| - { |
262 |
| - userID: 2, |
263 |
| - repositoryID: 2, |
264 |
| - commitRepoActionOptions: CommitRepoActionOptions{ |
265 |
| - RefFullName: "refName", |
266 |
| - OldCommitID: "oldCommitID", |
267 |
| - NewCommitID: "newCommitID", |
268 |
| - Commits: &PushCommits{ |
269 |
| - avatars: make(map[string]string), |
270 |
| - Commits: []*PushCommit{ |
271 |
| - { |
272 |
| - Sha1: "abcdef1", |
273 |
| - CommitterEmail: "[email protected]", |
274 |
| - CommitterName: "User Two", |
275 |
| - |
276 |
| - AuthorName: "User Four", |
277 |
| - Message: "message1", |
278 |
| - }, |
279 |
| - { |
280 |
| - Sha1: "abcdef2", |
281 |
| - CommitterEmail: "[email protected]", |
282 |
| - CommitterName: "User Two", |
283 |
| - |
284 |
| - AuthorName: "User Two", |
285 |
| - Message: "message2", |
286 |
| - }, |
287 |
| - }, |
288 |
| - Len: 2, |
289 |
| - }, |
290 |
| - }, |
291 |
| - action: Action{ |
292 |
| - OpType: ActionCommitRepo, |
293 |
| - RefName: "refName", |
294 |
| - }, |
295 |
| - }, |
296 |
| - { |
297 |
| - userID: 2, |
298 |
| - repositoryID: 1, |
299 |
| - commitRepoActionOptions: CommitRepoActionOptions{ |
300 |
| - RefFullName: git.TagPrefix + "v1.1", |
301 |
| - OldCommitID: git.EmptySHA, |
302 |
| - NewCommitID: "newCommitID", |
303 |
| - Commits: &PushCommits{}, |
304 |
| - }, |
305 |
| - action: Action{ |
306 |
| - OpType: ActionPushTag, |
307 |
| - RefName: "v1.1", |
308 |
| - }, |
309 |
| - }, |
310 |
| - { |
311 |
| - userID: 2, |
312 |
| - repositoryID: 1, |
313 |
| - commitRepoActionOptions: CommitRepoActionOptions{ |
314 |
| - RefFullName: git.TagPrefix + "v1.1", |
315 |
| - OldCommitID: "oldCommitID", |
316 |
| - NewCommitID: git.EmptySHA, |
317 |
| - Commits: &PushCommits{}, |
318 |
| - }, |
319 |
| - action: Action{ |
320 |
| - OpType: ActionDeleteTag, |
321 |
| - RefName: "v1.1", |
322 |
| - }, |
323 |
| - }, |
324 |
| - { |
325 |
| - userID: 2, |
326 |
| - repositoryID: 1, |
327 |
| - commitRepoActionOptions: CommitRepoActionOptions{ |
328 |
| - RefFullName: git.BranchPrefix + "feature/1", |
329 |
| - OldCommitID: "oldCommitID", |
330 |
| - NewCommitID: git.EmptySHA, |
331 |
| - Commits: &PushCommits{}, |
332 |
| - }, |
333 |
| - action: Action{ |
334 |
| - OpType: ActionDeleteBranch, |
335 |
| - RefName: "feature/1", |
336 |
| - }, |
337 |
| - }, |
338 |
| - } |
339 |
| - |
340 |
| - for _, s := range samples { |
341 |
| - PrepareTestEnv(t) |
342 |
| - |
343 |
| - user := AssertExistsAndLoadBean(t, &User{ID: s.userID}).(*User) |
344 |
| - repo := AssertExistsAndLoadBean(t, &Repository{ID: s.repositoryID, OwnerID: user.ID}).(*Repository) |
345 |
| - repo.Owner = user |
346 |
| - |
347 |
| - s.commitRepoActionOptions.PusherName = user.Name |
348 |
| - s.commitRepoActionOptions.RepoOwnerID = user.ID |
349 |
| - s.commitRepoActionOptions.RepoName = repo.Name |
350 |
| - |
351 |
| - s.action.ActUserID = user.ID |
352 |
| - s.action.RepoID = repo.ID |
353 |
| - s.action.Repo = repo |
354 |
| - s.action.IsPrivate = repo.IsPrivate |
355 |
| - |
356 |
| - testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action) |
357 |
| - } |
358 |
| -} |
359 |
| - |
360 | 243 | func TestGetFeeds(t *testing.T) {
|
361 | 244 | // test with an individual user
|
362 | 245 | assert.NoError(t, PrepareTestDatabase())
|
|
0 commit comments