mirror of https://github.com/go-gitea/gitea
add test
This commit is contained in:
parent
69b76246b0
commit
0bfec1a3e8
|
@ -49,7 +49,43 @@
|
|||
-
|
||||
id: 5
|
||||
repo_id: 1
|
||||
name: 'new-branch-notification'
|
||||
name: 'new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 2
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 6
|
||||
repo_id: 1
|
||||
name: 'no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 2
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 7
|
||||
repo_id: 58
|
||||
name: 'master'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 1
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 8
|
||||
repo_id: 58
|
||||
name: 'user-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
|
@ -59,9 +95,9 @@
|
|||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 6
|
||||
repo_id: 1
|
||||
name: 'new-branch-no-notification'
|
||||
id: 9
|
||||
repo_id: 58
|
||||
name: 'user-fork-no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
|
@ -69,3 +105,99 @@
|
|||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 10
|
||||
repo_id: 59
|
||||
name: 'master'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 1
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 11
|
||||
repo_id: 59
|
||||
name: 'org-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 2
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 12
|
||||
repo_id: 59
|
||||
name: 'org-fork-no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 2
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 13
|
||||
repo_id: 60
|
||||
name: 'master'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 1
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 14
|
||||
repo_id: 60
|
||||
name: 'private-org-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 4
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 15
|
||||
repo_id: 60
|
||||
name: 'private-org-fork-no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 4
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 16
|
||||
repo_id: 60
|
||||
name: 'private-org-fork-no-permission-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 5
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
||||
-
|
||||
id: 17
|
||||
repo_id: 60
|
||||
name: 'private-org-fork-no-permission-no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 5
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
|
@ -8,7 +8,7 @@
|
|||
default_branch: master
|
||||
num_watches: 4
|
||||
num_stars: 0
|
||||
num_forks: 0
|
||||
num_forks: 3
|
||||
num_issues: 2
|
||||
num_closed_issues: 1
|
||||
num_pulls: 3
|
||||
|
@ -1662,3 +1662,93 @@
|
|||
is_private: false
|
||||
status: 0
|
||||
num_issues: 0
|
||||
|
||||
-
|
||||
id: 58
|
||||
owner_id: 1
|
||||
owner_name: user1
|
||||
lower_name: user_fork_repo1
|
||||
name: user_fork_repo1
|
||||
num_watches: 0
|
||||
num_stars: 0
|
||||
num_forks: 0
|
||||
num_issues: 0
|
||||
num_closed_issues: 0
|
||||
num_pulls: 0
|
||||
num_closed_pulls: 0
|
||||
num_milestones: 0
|
||||
num_closed_milestones: 0
|
||||
num_projects: 0
|
||||
num_closed_projects: 0
|
||||
is_private: false
|
||||
is_empty: false
|
||||
is_archived: false
|
||||
is_mirror: false
|
||||
status: 0
|
||||
is_fork: true
|
||||
fork_id: 1
|
||||
is_template: false
|
||||
template_id: 0
|
||||
size: 0
|
||||
is_fsck_enabled: true
|
||||
close_issues_via_commit_in_any_branch: false
|
||||
|
||||
-
|
||||
id: 59
|
||||
owner_id: 3
|
||||
owner_name: user3
|
||||
lower_name: org_fork_repo1
|
||||
name: org_fork_repo1
|
||||
num_watches: 0
|
||||
num_stars: 0
|
||||
num_forks: 0
|
||||
num_issues: 0
|
||||
num_closed_issues: 0
|
||||
num_pulls: 0
|
||||
num_closed_pulls: 0
|
||||
num_milestones: 0
|
||||
num_closed_milestones: 0
|
||||
num_projects: 0
|
||||
num_closed_projects: 0
|
||||
is_private: false
|
||||
is_empty: false
|
||||
is_archived: false
|
||||
is_mirror: false
|
||||
status: 0
|
||||
is_fork: true
|
||||
fork_id: 1
|
||||
is_template: false
|
||||
template_id: 0
|
||||
size: 0
|
||||
is_fsck_enabled: true
|
||||
close_issues_via_commit_in_any_branch: false
|
||||
|
||||
-
|
||||
id: 60
|
||||
owner_id: 23
|
||||
owner_name: privated_org
|
||||
lower_name: private_org_fork_repo1
|
||||
name: private_org_fork_repo1
|
||||
num_watches: 0
|
||||
num_stars: 0
|
||||
num_forks: 0
|
||||
num_issues: 0
|
||||
num_closed_issues: 0
|
||||
num_pulls: 0
|
||||
num_closed_pulls: 0
|
||||
num_milestones: 0
|
||||
num_closed_milestones: 0
|
||||
num_projects: 0
|
||||
num_closed_projects: 0
|
||||
is_private: true
|
||||
is_empty: false
|
||||
is_archived: false
|
||||
is_mirror: false
|
||||
status: 0
|
||||
is_fork: true
|
||||
fork_id: 1
|
||||
is_template: false
|
||||
template_id: 0
|
||||
size: 0
|
||||
is_fsck_enabled: true
|
||||
close_issues_via_commit_in_any_branch: false
|
|
@ -217,3 +217,25 @@
|
|||
num_members: 1
|
||||
includes_all_repositories: false
|
||||
can_create_org_repo: true
|
||||
|
||||
-
|
||||
id: 21
|
||||
org_id: 23
|
||||
lower_name: team21readcode
|
||||
name: team14WriteAuth
|
||||
authorize: 1 # read
|
||||
num_repos: 1
|
||||
num_members: 1
|
||||
includes_all_repositories: false
|
||||
can_create_org_repo: true
|
||||
|
||||
-
|
||||
id: 22
|
||||
org_id: 23
|
||||
lower_name: team22noreadcode
|
||||
name: team14WriteAuth
|
||||
authorize: 0 # no access
|
||||
num_repos: 1
|
||||
num_members: 1
|
||||
includes_all_repositories: false
|
||||
can_create_org_repo: true
|
|
@ -62,4 +62,16 @@
|
|||
id: 11
|
||||
org_id: 17
|
||||
team_id: 9
|
||||
repo_id: 24
|
||||
repo_id: 24
|
||||
|
||||
-
|
||||
id: 12
|
||||
org_id: 23
|
||||
team_id: 21
|
||||
repo_id: 60
|
||||
|
||||
-
|
||||
id: 13
|
||||
org_id: 23
|
||||
team_id: 22
|
||||
repo_id: 60
|
|
@ -280,3 +280,15 @@
|
|||
team_id: 20
|
||||
type: 9 # package
|
||||
access_mode: 2
|
||||
|
||||
-
|
||||
id: 48
|
||||
team_id: 21
|
||||
type: 1 # code
|
||||
access_mode: 1
|
||||
|
||||
-
|
||||
id: 49
|
||||
team_id: 22
|
||||
type: 1 # code
|
||||
access_mode: 0
|
|
@ -123,3 +123,15 @@
|
|||
org_id: 36
|
||||
team_id: 20
|
||||
uid: 5
|
||||
|
||||
-
|
||||
id: 22
|
||||
org_id: 23
|
||||
team_id: 21
|
||||
uid: 4
|
||||
|
||||
-
|
||||
id: 23
|
||||
org_id: 23
|
||||
team_id: 22
|
||||
uid: 5
|
|
@ -29,7 +29,7 @@
|
|||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 0
|
||||
num_repos: 1
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
|
@ -103,7 +103,7 @@
|
|||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 3
|
||||
num_repos: 4
|
||||
num_teams: 5
|
||||
num_members: 3
|
||||
visibility: 0
|
||||
|
@ -843,9 +843,9 @@
|
|||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 2
|
||||
num_teams: 2
|
||||
num_members: 1
|
||||
num_repos: 3
|
||||
num_teams: 4
|
||||
num_members: 2
|
||||
visibility: 2
|
||||
repo_admin_change_team_access: false
|
||||
theme: ""
|
||||
|
|
|
@ -189,21 +189,33 @@ func TestFindRecentlyPushedNewBranches(t *testing.T) {
|
|||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
|
||||
// test new branch of the repo
|
||||
branches, err := git_model.FindRecentlyPushedNewBranches(db.DefaultContext, repo, user1, 1689838760)
|
||||
// test new branch of the repo and org fork repo
|
||||
// user2 is the owner of the repo and the organization
|
||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
branches, err := git_model.FindRecentlyPushedNewBranches(db.DefaultContext, repo, user2, 1689838760)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(branches))
|
||||
assert.Equal(t, "new-commit", branches[0].Name)
|
||||
assert.Equal(t, "org-fork-new-commit", branches[1].Name)
|
||||
|
||||
// test new branch from user public and private fork repo
|
||||
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
branches, err = git_model.FindRecentlyPushedNewBranches(db.DefaultContext, repo, user1, 1689838760)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(branches))
|
||||
assert.Equal(t, "new-branch-notification", branches[0].Name)
|
||||
assert.Equal(t, "user-fork-new-commit", branches[0].Name)
|
||||
|
||||
// TODO: test new branch from user fork repo
|
||||
// test new branch from private org with code permisstion repo
|
||||
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
|
||||
branches, err = git_model.FindRecentlyPushedNewBranches(db.DefaultContext, repo, user4, 1689838760)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(branches))
|
||||
assert.Equal(t, "private-org-fork-new-commit", branches[0].Name)
|
||||
|
||||
// TODO: test new branch from org fork repo
|
||||
|
||||
// TODO: test new branch from private user repo
|
||||
|
||||
// TODO: test new branch from private org with code permisstion repo
|
||||
|
||||
// TODO: test new branch from private org with no code permisstion repo
|
||||
// test new branch from private org with no code permisstion repo
|
||||
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5})
|
||||
branches, err = git_model.FindRecentlyPushedNewBranches(db.DefaultContext, repo, user5, 1689838760)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(branches))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue