feat: vendor gitea 1.16.2
This commit is contained in:
@@ -30,6 +30,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
||||
if err != nil || resp.StatusCode != http.StatusOK {
|
||||
t.Skipf("Can't access test repo, skipping %s", t.Name())
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
ctx := t.Context()
|
||||
downloader, err := NewGitlabDownloader(ctx, "https://gitlab.com", "gitea/test_repo", gitlabPersonalAccessToken)
|
||||
if err != nil {
|
||||
@@ -58,14 +59,14 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
||||
{
|
||||
Title: "1.1.0",
|
||||
Created: time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC),
|
||||
Updated: timePtr(time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC)),
|
||||
Updated: new(time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC)),
|
||||
State: "active",
|
||||
},
|
||||
{
|
||||
Title: "1.0.0",
|
||||
Created: time.Date(2019, 11, 28, 8, 42, 30, 301000000, time.UTC),
|
||||
Updated: timePtr(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
|
||||
Closed: timePtr(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
|
||||
Updated: new(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
|
||||
Closed: new(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
|
||||
State: "closed",
|
||||
},
|
||||
}, milestones)
|
||||
@@ -160,7 +161,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
||||
Content: "open_mouth",
|
||||
},
|
||||
},
|
||||
Closed: timePtr(time.Date(2019, 11, 28, 8, 46, 23, 275000000, time.UTC)),
|
||||
Closed: new(time.Date(2019, 11, 28, 8, 46, 23, 275000000, time.UTC)),
|
||||
},
|
||||
{
|
||||
Number: 2,
|
||||
@@ -209,7 +210,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
||||
Content: "hearts",
|
||||
},
|
||||
},
|
||||
Closed: timePtr(time.Date(2019, 11, 28, 8, 45, 44, 959000000, time.UTC)),
|
||||
Closed: new(time.Date(2019, 11, 28, 8, 45, 44, 959000000, time.UTC)),
|
||||
},
|
||||
}, issues)
|
||||
|
||||
@@ -357,7 +358,7 @@ func gitlabClientMockTeardown(server *httptest.Server) {
|
||||
}
|
||||
|
||||
type reviewTestCase struct {
|
||||
repoID, prID, reviewerID int
|
||||
repoID, prID, reviewerID int64
|
||||
reviewerName string
|
||||
createdAt, updatedAt *time.Time
|
||||
expectedCreatedAt time.Time
|
||||
@@ -382,8 +383,8 @@ func convertTestCase(t reviewTestCase) (func(w http.ResponseWriter, r *http.Requ
|
||||
fmt.Fprint(w, `
|
||||
{
|
||||
"id": 5,
|
||||
"iid": `+strconv.Itoa(t.prID)+`,
|
||||
"project_id": `+strconv.Itoa(t.repoID)+`,
|
||||
"iid": `+strconv.FormatInt(t.prID, 10)+`,
|
||||
"project_id": `+strconv.FormatInt(t.repoID, 10)+`,
|
||||
"title": "Approvals API",
|
||||
"description": "Test",
|
||||
"state": "opened",
|
||||
@@ -397,7 +398,7 @@ func convertTestCase(t reviewTestCase) (func(w http.ResponseWriter, r *http.Requ
|
||||
"user": {
|
||||
"name": "Administrator",
|
||||
"username": "`+t.reviewerName+`",
|
||||
"id": `+strconv.Itoa(t.reviewerID)+`,
|
||||
"id": `+strconv.FormatInt(t.reviewerID, 10)+`,
|
||||
"state": "active",
|
||||
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon",
|
||||
"web_url": "http://localhost:3000/root"
|
||||
@@ -407,8 +408,8 @@ func convertTestCase(t reviewTestCase) (func(w http.ResponseWriter, r *http.Requ
|
||||
}`)
|
||||
}
|
||||
review := base.Review{
|
||||
IssueIndex: int64(t.prID),
|
||||
ReviewerID: int64(t.reviewerID),
|
||||
IssueIndex: t.prID,
|
||||
ReviewerID: t.reviewerID,
|
||||
ReviewerName: t.reviewerName,
|
||||
CreatedAt: t.expectedCreatedAt,
|
||||
State: "APPROVED",
|
||||
@@ -421,7 +422,7 @@ func TestGitlabGetReviews(t *testing.T) {
|
||||
mux, server, client := gitlabClientMockSetup(t)
|
||||
defer gitlabClientMockTeardown(server)
|
||||
|
||||
repoID := 1324
|
||||
var repoID int64 = 1324
|
||||
ctx := t.Context()
|
||||
downloader := &GitlabDownloader{
|
||||
client: client,
|
||||
@@ -462,8 +463,7 @@ func TestGitlabGetReviews(t *testing.T) {
|
||||
mock, review := convertTestCase(testCase)
|
||||
mux.HandleFunc(fmt.Sprintf("/api/v4/projects/%d/merge_requests/%d/approvals", testCase.repoID, testCase.prID), mock)
|
||||
|
||||
id := int64(testCase.prID)
|
||||
rvs, err := downloader.GetReviews(ctx, &base.Issue{Number: id, ForeignIndex: id})
|
||||
rvs, err := downloader.GetReviews(ctx, &base.Issue{Number: testCase.prID, ForeignIndex: testCase.prID})
|
||||
assert.NoError(t, err)
|
||||
assertReviewsEqual(t, []*base.Review{&review}, rvs)
|
||||
}
|
||||
@@ -519,18 +519,10 @@ func TestNoteToComment(t *testing.T) {
|
||||
downloader := &GitlabDownloader{}
|
||||
|
||||
now := time.Now()
|
||||
makeTestNote := func(id int, body string, system bool) gitlab.Note {
|
||||
makeTestNote := func(id int64, body string, system bool) gitlab.Note {
|
||||
return gitlab.Note{
|
||||
ID: id,
|
||||
Author: struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
WebURL string `json:"web_url"`
|
||||
}{
|
||||
Author: gitlab.NoteAuthor{
|
||||
ID: 72,
|
||||
Email: "test@example.com",
|
||||
Username: "test",
|
||||
|
||||
Reference in New Issue
Block a user