@@ -12,8 +12,6 @@ import (
12
12
"testing"
13
13
14
14
auth_model "code.gitea.io/gitea/models/auth"
15
- "code.gitea.io/gitea/models/unittest"
16
- user_model "code.gitea.io/gitea/models/user"
17
15
"code.gitea.io/gitea/modules/json"
18
16
"code.gitea.io/gitea/modules/setting"
19
17
api "code.gitea.io/gitea/modules/structs"
@@ -40,40 +38,24 @@ func TestRepoCommits(t *testing.T) {
40
38
41
39
func Test_ReposGitCommitListNotMaster (t * testing.T ) {
42
40
defer tests .PrepareTestEnv (t )()
43
- user := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
44
- // Login as User2.
45
- session := loginUser (t , user .Name )
46
-
47
- // Test getting commits (Page 1)
48
- req := NewRequestf (t , "GET" , "/%s/repo16/commits/branch/master" , user .Name )
41
+ session := loginUser (t , "user2" )
42
+ req := NewRequest (t , "GET" , "/user2/repo16/commits/branch/master" )
49
43
resp := session .MakeRequest (t , req , http .StatusOK )
50
44
51
45
doc := NewHTMLParser (t , resp .Body )
52
- commits := []string {}
46
+ var commits []string
53
47
doc .doc .Find ("#commits-table .commit-id-short" ).Each (func (i int , s * goquery.Selection ) {
54
- commitURL , exists := s .Attr ("href" )
55
- assert .True (t , exists )
56
- assert .NotEmpty (t , commitURL )
48
+ commitURL , _ := s .Attr ("href" )
57
49
commits = append (commits , path .Base (commitURL ))
58
50
})
51
+ assert .Equal (t , []string {"69554a64c1e6030f051e5c3f94bfbd773cd6a324" , "27566bd5738fc8b4e3fef3c5e72cce608537bd95" , "5099b81332712fe655e34e8dd63574f503f61811" }, commits )
59
52
60
- assert .Len (t , commits , 3 )
61
- assert .Equal (t , "69554a64c1e6030f051e5c3f94bfbd773cd6a324" , commits [0 ])
62
- assert .Equal (t , "27566bd5738fc8b4e3fef3c5e72cce608537bd95" , commits [1 ])
63
- assert .Equal (t , "5099b81332712fe655e34e8dd63574f503f61811" , commits [2 ])
64
-
65
- userNames := []string {}
53
+ var userHrefs []string
66
54
doc .doc .Find ("#commits-table .author-wrapper" ).Each (func (i int , s * goquery.Selection ) {
67
- userPath , exists := s .Attr ("href" )
68
- assert .True (t , exists )
69
- assert .NotEmpty (t , userPath )
70
- userNames = append (userNames , path .Base (userPath ))
55
+ userHref , _ := s .Attr ("href" )
56
+ userHrefs = append (userHrefs , userHref )
71
57
})
72
-
73
- assert .Len (t , userNames , 3 )
74
- assert .Equal (t , "User2" , userNames [0 ])
75
- assert .Equal (t , "user21" , userNames [1 ])
76
- assert .Equal (t , "User2" , userNames [2 ])
58
+ assert .Equal (t , []string {"/user2" , "/user21" , "/user2" }, userHrefs )
77
59
}
78
60
79
61
func doTestRepoCommitWithStatus (t * testing.T , state string , classes ... string ) {
0 commit comments