mirror of https://github.com/go-gitea/gitea
fix tests
This commit is contained in:
parent
f9b4085b57
commit
86892d458d
|
@ -4,6 +4,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -27,6 +28,7 @@ func TestFixtureGeneration(t *testing.T) {
|
|||
return
|
||||
}
|
||||
data := string(util.NormalizeEOL(bytes))
|
||||
fmt.Println(expected)
|
||||
assert.True(t, data == expected, "Differences detected for %s.yml", name)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,127 +24,127 @@
|
|||
|
||||
-
|
||||
id: 5
|
||||
user_id: 2
|
||||
repo_id: 59
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 6
|
||||
user_id: 4
|
||||
repo_id: 3
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 7
|
||||
id: 6
|
||||
user_id: 4
|
||||
repo_id: 4
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 8
|
||||
id: 7
|
||||
user_id: 4
|
||||
repo_id: 40
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 9
|
||||
id: 8
|
||||
user_id: 15
|
||||
repo_id: 21
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 9
|
||||
user_id: 15
|
||||
repo_id: 22
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 10
|
||||
user_id: 15
|
||||
repo_id: 22
|
||||
mode: 2
|
||||
repo_id: 23
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 11
|
||||
user_id: 15
|
||||
repo_id: 23
|
||||
repo_id: 24
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 12
|
||||
user_id: 15
|
||||
repo_id: 24
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 13
|
||||
user_id: 15
|
||||
repo_id: 32
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 14
|
||||
id: 13
|
||||
user_id: 18
|
||||
repo_id: 21
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 15
|
||||
id: 14
|
||||
user_id: 18
|
||||
repo_id: 22
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 16
|
||||
id: 15
|
||||
user_id: 18
|
||||
repo_id: 23
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 17
|
||||
id: 16
|
||||
user_id: 18
|
||||
repo_id: 24
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 18
|
||||
user_id: 18
|
||||
repo_id: 60
|
||||
mode: 1
|
||||
|
||||
-
|
||||
id: 19
|
||||
id: 17
|
||||
user_id: 20
|
||||
repo_id: 24
|
||||
mode: 1
|
||||
|
||||
-
|
||||
id: 20
|
||||
id: 18
|
||||
user_id: 20
|
||||
repo_id: 27
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 21
|
||||
id: 19
|
||||
user_id: 20
|
||||
repo_id: 28
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 22
|
||||
id: 20
|
||||
user_id: 29
|
||||
repo_id: 4
|
||||
mode: 2
|
||||
|
||||
-
|
||||
id: 23
|
||||
id: 21
|
||||
user_id: 29
|
||||
repo_id: 24
|
||||
mode: 1
|
||||
|
||||
-
|
||||
id: 24
|
||||
id: 22
|
||||
user_id: 31
|
||||
repo_id: 27
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 25
|
||||
id: 23
|
||||
user_id: 31
|
||||
repo_id: 28
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 24
|
||||
user_id: 40
|
||||
repo_id: 59
|
||||
mode: 4
|
||||
|
||||
-
|
||||
id: 25
|
||||
user_id: 41
|
||||
repo_id: 60
|
||||
mode: 1
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
name: 'new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 2
|
||||
commit_time: 1489927680
|
||||
pusher_id: 39
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -65,7 +65,7 @@
|
|||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 2
|
||||
pusher_id: 39
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -88,8 +88,8 @@
|
|||
name: 'user-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 39
|
||||
commit_time: 1489927680
|
||||
pusher_id: 40
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -101,7 +101,7 @@
|
|||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 39
|
||||
pusher_id: 40
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -124,8 +124,8 @@
|
|||
name: 'org-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 2
|
||||
commit_time: 1489927691
|
||||
pusher_id: 39
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -136,8 +136,8 @@
|
|||
name: 'org-fork-no-commit'
|
||||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 2
|
||||
commit_time: 1489927691
|
||||
pusher_id: 39
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -160,8 +160,8 @@
|
|||
name: 'private-org-fork-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 18
|
||||
commit_time: 1489927680
|
||||
pusher_id: 41
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -173,7 +173,7 @@
|
|||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 18
|
||||
pusher_id: 41
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -184,8 +184,8 @@
|
|||
name: 'private-org-fork-no-permission-new-commit'
|
||||
commit_id: 'cb24c347e328d83c1e0c3c908a6b2c0a2fcb8a3d'
|
||||
commit_message: 'add'
|
||||
commit_time: 1689838761
|
||||
pusher_id: 5
|
||||
commit_time: 1489927680
|
||||
pusher_id: 42
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
@ -197,7 +197,7 @@
|
|||
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
|
||||
commit_message: 'Initial commit'
|
||||
commit_time: 1489927679
|
||||
pusher_id: 5
|
||||
pusher_id: 42
|
||||
is_deleted: false
|
||||
deleted_by_id: 0
|
||||
deleted_unix: 0
|
||||
|
|
|
@ -102,18 +102,18 @@
|
|||
|
||||
-
|
||||
id: 18
|
||||
uid: 2
|
||||
uid: 39
|
||||
org_id: 37
|
||||
is_public: false
|
||||
|
||||
-
|
||||
id: 19
|
||||
uid: 18
|
||||
uid: 41
|
||||
org_id: 38
|
||||
is_public: false
|
||||
|
||||
-
|
||||
id: 20
|
||||
uid: 5
|
||||
uid: 42
|
||||
org_id: 38
|
||||
is_public: false
|
||||
|
|
|
@ -607,3 +607,15 @@
|
|||
repo_id: 52
|
||||
type: 1
|
||||
created_unix: 946684810
|
||||
|
||||
-
|
||||
id: 91
|
||||
repo_id: 59
|
||||
type: 1
|
||||
created_unix: 946684810
|
||||
|
||||
-
|
||||
id: 92
|
||||
repo_id: 60
|
||||
type: 1
|
||||
created_unix: 946684810
|
||||
|
|
|
@ -1665,10 +1665,10 @@
|
|||
|
||||
-
|
||||
id: 58
|
||||
owner_id: 39
|
||||
owner_name: user39
|
||||
lower_name: user_fork_repo1
|
||||
name: user_fork_repo1
|
||||
owner_id: 40
|
||||
owner_name: user40
|
||||
lower_name: user_fork_repo
|
||||
name: user_fork_repo
|
||||
num_watches: 0
|
||||
num_stars: 0
|
||||
num_forks: 0
|
||||
|
|
|
@ -128,16 +128,16 @@
|
|||
id: 22
|
||||
org_id: 37
|
||||
team_id: 21
|
||||
uid: 2
|
||||
uid: 40
|
||||
|
||||
-
|
||||
id: 23
|
||||
org_id: 38
|
||||
team_id: 23
|
||||
uid: 18
|
||||
uid: 41
|
||||
|
||||
-
|
||||
id: 24
|
||||
org_id: 38
|
||||
team_id: 24
|
||||
uid: 5
|
||||
uid: 42
|
||||
|
|
|
@ -288,7 +288,7 @@
|
|||
num_followers: 1
|
||||
num_following: 1
|
||||
num_stars: 0
|
||||
num_repos: 1
|
||||
num_repos: 0
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
|
@ -1436,10 +1436,121 @@
|
|||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 0
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
repo_admin_change_team_access: false
|
||||
theme: ""
|
||||
keep_activity_private: false
|
||||
|
||||
-
|
||||
id: 40
|
||||
lower_name: user40
|
||||
name: user40
|
||||
full_name: user40
|
||||
email: user40@example.com
|
||||
keep_email_private: true
|
||||
email_notifications_preference: enabled
|
||||
passwd: ZogKvWdyEx:password
|
||||
passwd_hash_algo: dummy
|
||||
must_change_password: false
|
||||
login_source: 0
|
||||
login_name: user40
|
||||
type: 0
|
||||
salt: ZogKvWdyEx
|
||||
max_repo_creation: -1
|
||||
is_active: true
|
||||
is_admin: false
|
||||
is_restricted: false
|
||||
allow_git_hook: false
|
||||
allow_import_local: false
|
||||
allow_create_organization: true
|
||||
prohibit_login: false
|
||||
avatar: avatar40
|
||||
avatar_email: user40@example.com
|
||||
use_custom_avatar: false
|
||||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 1
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
repo_admin_change_team_access: false
|
||||
theme: ""
|
||||
keep_activity_private: false
|
||||
keep_activity_private: false
|
||||
|
||||
-
|
||||
id: 41
|
||||
lower_name: user41
|
||||
name: user41
|
||||
full_name: user41
|
||||
email: user41@example.com
|
||||
keep_email_private: true
|
||||
email_notifications_preference: enabled
|
||||
passwd: ZogKvWdyEx:password
|
||||
passwd_hash_algo: dummy
|
||||
must_change_password: false
|
||||
login_source: 0
|
||||
login_name: user41
|
||||
type: 0
|
||||
salt: ZogKvWdyEx
|
||||
max_repo_creation: -1
|
||||
is_active: true
|
||||
is_admin: false
|
||||
is_restricted: false
|
||||
allow_git_hook: false
|
||||
allow_import_local: false
|
||||
allow_create_organization: true
|
||||
prohibit_login: false
|
||||
avatar: avatar41
|
||||
avatar_email: user41@example.com
|
||||
use_custom_avatar: false
|
||||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 0
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
repo_admin_change_team_access: false
|
||||
theme: ""
|
||||
keep_activity_private: false
|
||||
|
||||
-
|
||||
id: 42
|
||||
lower_name: user42
|
||||
name: user42
|
||||
full_name: user42
|
||||
email: user42@example.com
|
||||
keep_email_private: true
|
||||
email_notifications_preference: enabled
|
||||
passwd: ZogKvWdyEx:password
|
||||
passwd_hash_algo: dummy
|
||||
must_change_password: false
|
||||
login_source: 0
|
||||
login_name: user42
|
||||
type: 0
|
||||
salt: ZogKvWdyEx
|
||||
max_repo_creation: -1
|
||||
is_active: true
|
||||
is_admin: false
|
||||
is_restricted: false
|
||||
allow_git_hook: false
|
||||
allow_import_local: false
|
||||
allow_create_organization: true
|
||||
prohibit_login: false
|
||||
avatar: avatar42
|
||||
avatar_email: user42@example.com
|
||||
use_custom_avatar: false
|
||||
num_followers: 0
|
||||
num_following: 0
|
||||
num_stars: 0
|
||||
num_repos: 0
|
||||
num_teams: 0
|
||||
num_members: 0
|
||||
visibility: 0
|
||||
repo_admin_change_team_access: false
|
||||
theme: ""
|
||||
keep_activity_private: false
|
||||
|
|
|
@ -189,52 +189,64 @@ func TestFindRecentlyPushedNewBranches(t *testing.T) {
|
|||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5})
|
||||
user18 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 18})
|
||||
user39 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 39})
|
||||
user40 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 40})
|
||||
user41 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 41})
|
||||
user42 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 42})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
actor *user_model.User
|
||||
count int
|
||||
want []string
|
||||
name string
|
||||
actor *user_model.User
|
||||
count int
|
||||
commitAfterUnix int64
|
||||
want []string
|
||||
}{
|
||||
// user2 is the owner of the repo and the organization
|
||||
{
|
||||
name: "new branch of the repo and org fork repo",
|
||||
actor: user2,
|
||||
count: 2,
|
||||
want: []string{"new-commit", "org-fork-new-commit"},
|
||||
name: "new branch of the repo",
|
||||
actor: user39,
|
||||
count: 2,
|
||||
commitAfterUnix: 1489927670,
|
||||
want: []string{"new-commit", "org-fork-new-commit"},
|
||||
},
|
||||
{
|
||||
name: "new branch from user fork repo",
|
||||
actor: user39,
|
||||
count: 1,
|
||||
want: []string{"user-fork-new-commit"},
|
||||
name: "new branch of org fork repo",
|
||||
actor: user39,
|
||||
count: 1,
|
||||
commitAfterUnix: 1489927690,
|
||||
want: []string{"org-fork-new-commit"},
|
||||
},
|
||||
{
|
||||
name: "new branch from private org with code permisstion repo",
|
||||
actor: user18,
|
||||
count: 1,
|
||||
want: []string{"private-org-fork-new-commit"},
|
||||
name: "new branch from user fork repo",
|
||||
actor: user40,
|
||||
count: 1,
|
||||
commitAfterUnix: 1489927670,
|
||||
want: []string{"user-fork-new-commit"},
|
||||
},
|
||||
{
|
||||
name: "new branch from private org with no code permisstion repo",
|
||||
actor: user5,
|
||||
count: 0,
|
||||
want: []string{"new-commit", "org-fork-new-commit"},
|
||||
name: "new branch from private org with code permisstion repo",
|
||||
actor: user41,
|
||||
count: 1,
|
||||
commitAfterUnix: 1489927670,
|
||||
want: []string{"private-org-fork-new-commit"},
|
||||
},
|
||||
{
|
||||
name: "new branch from private org with no code permisstion repo",
|
||||
actor: user42,
|
||||
count: 0,
|
||||
commitAfterUnix: 1489927670,
|
||||
want: []string{"new-commit", "org-fork-new-commit"},
|
||||
},
|
||||
}
|
||||
|
||||
opts := &git_model.FindRecentlyPushedNewBranchesOptions{
|
||||
Repo: repo,
|
||||
BaseRepo: repo,
|
||||
CommitAfterUnix: 1689838760,
|
||||
Repo: repo,
|
||||
BaseRepo: repo,
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
opts.Actor = tt.actor
|
||||
opts.CommitAfterUnix = tt.commitAfterUnix
|
||||
branches, err := git_model.FindRecentlyPushedNewBranches(db.DefaultContext, opts)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.count, len(branches))
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestNodeinfo(t *testing.T) {
|
|||
DecodeJSON(t, resp, &nodeinfo)
|
||||
assert.True(t, nodeinfo.OpenRegistrations)
|
||||
assert.Equal(t, "gitea", nodeinfo.Software.Name)
|
||||
assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
|
||||
assert.Equal(t, 29, nodeinfo.Usage.Users.Total)
|
||||
assert.Equal(t, 18, nodeinfo.Usage.LocalPosts)
|
||||
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue