Skip to content

Commit d23878b

Browse files
committed
add test
1 parent 58ff8f4 commit d23878b

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

models/fixtures/comment.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,22 @@
8383
issue_id: 2 # in repo_id 1
8484
review_id: 20
8585
created_unix: 946684810
86+
87+
-
88+
id: 10
89+
type: 22 # review
90+
poster_id: 5
91+
issue_id: 3 # in repo_id 1
92+
content: "reviewed by user5"
93+
review_id: 21
94+
created_unix: 946684816
95+
96+
-
97+
id: 11
98+
type: 27 # review request
99+
poster_id: 2
100+
issue_id: 3 # in repo_id 1
101+
content: "review request for user5"
102+
review_id: 22
103+
assignee_id: 5
104+
created_unix: 946684817

models/fixtures/review.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,22 @@
179179
content: "Review Comment"
180180
updated_unix: 946684810
181181
created_unix: 946684810
182+
183+
-
184+
id: 21
185+
type: 2
186+
reviewer_id: 5
187+
issue_id: 3
188+
content: "reviewed by user5"
189+
commit_id: 4a357436d925b5c974181ff12a994538ddc5a269
190+
updated_unix: 946684816
191+
created_unix: 946684816
192+
193+
-
194+
id: 22
195+
type: 4
196+
reviewer_id: 5
197+
issue_id: 3
198+
content: "review request for user5"
199+
updated_unix: 946684817
200+
created_unix: 946684817
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package integration
5+
6+
import (
7+
"net/http"
8+
"net/url"
9+
"testing"
10+
11+
pull_service "code.gitea.io/gitea/services/pull"
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func TestListPullCommits(t *testing.T) {
16+
onGiteaRun(t, func(t *testing.T, u *url.URL) {
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+
if assert.Len(t, pullCommitList.Commits, 2) {
28+
assert.Equal(t, "5f22f7d0d95d614d25a5b68592adb345a4b5c7fd", pullCommitList.Commits[0].ID)
29+
assert.Equal(t, "4a357436d925b5c974181ff12a994538ddc5a269", pullCommitList.Commits[1].ID)
30+
}
31+
assert.Equal(t, "4a357436d925b5c974181ff12a994538ddc5a269", pullCommitList.LastReviewCommitSha)
32+
})
33+
}

0 commit comments

Comments
 (0)