@@ -5,30 +5,33 @@ package integration
5
5
6
6
import (
7
7
"net/http"
8
- "net/url"
9
8
"testing"
10
9
11
10
pull_service "code.gitea.io/gitea/services/pull"
12
11
13
12
"github.com/stretchr/testify/assert"
13
+ "github.com/stretchr/testify/require"
14
14
)
15
15
16
16
func TestListPullCommits (t * testing.T ) {
17
- onGiteaRun (t , func (t * testing.T , u * url.URL ) {
18
- session := loginUser (t , "user5" )
19
- req := NewRequest (t , "GET" , "/user2/repo1/pulls/3/commits/list" )
20
- resp := session .MakeRequest (t , req , http .StatusOK )
21
-
22
- var pullCommitList struct {
23
- Commits []pull_service.CommitInfo `json:"commits"`
24
- LastReviewCommitSha string `json:"last_review_commit_sha"`
25
- }
26
- DecodeJSON (t , resp , & pullCommitList )
27
-
28
- if assert .Len (t , pullCommitList .Commits , 2 ) {
29
- assert .Equal (t , "985f0301dba5e7b34be866819cd15ad3d8f508ee" , pullCommitList .Commits [0 ].ID )
30
- assert .Equal (t , "5c050d3b6d2db231ab1f64e324f1b6b9a0b181c2" , pullCommitList .Commits [1 ].ID )
31
- }
32
- assert .Equal (t , "4a357436d925b5c974181ff12a994538ddc5a269" , pullCommitList .LastReviewCommitSha )
17
+ session := loginUser (t , "user5" )
18
+ req := NewRequest (t , "GET" , "/user2/repo1/pulls/3/commits/list" )
19
+ resp := session .MakeRequest (t , req , http .StatusOK )
20
+
21
+ var pullCommitList struct {
22
+ Commits []pull_service.CommitInfo `json:"commits"`
23
+ LastReviewCommitSha string `json:"last_review_commit_sha"`
24
+ }
25
+ DecodeJSON (t , resp , & pullCommitList )
26
+
27
+ require .Len (t , pullCommitList .Commits , 2 )
28
+ assert .Equal (t , "985f0301dba5e7b34be866819cd15ad3d8f508ee" , pullCommitList .Commits [0 ].ID )
29
+ assert .Equal (t , "5c050d3b6d2db231ab1f64e324f1b6b9a0b181c2" , pullCommitList .Commits [1 ].ID )
30
+ assert .Equal (t , "4a357436d925b5c974181ff12a994538ddc5a269" , pullCommitList .LastReviewCommitSha )
31
+
32
+ t .Run ("CommitBlobExcerpt" , func (t * testing.T ) {
33
+ req = NewRequest (t , "GET" , "/user2/repo1/blob_excerpt/985f0301dba5e7b34be866819cd15ad3d8f508ee?last_left=0&last_right=0&left=2&right=2&left_hunk_size=2&right_hunk_size=2&path=README.md&style=split&direction=up" )
34
+ resp = session .MakeRequest (t , req , http .StatusOK )
35
+ assert .Contains (t , resp .Body .String (), `<td class="lines-code lines-code-new"><code class="code-inner"># repo1</code>` )
33
36
})
34
37
}
0 commit comments