Skip to content

Commit ef73d4e

Browse files
committed
Fix test
1 parent 5ff3335 commit ef73d4e

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

modules/migrations/gitea_downloader_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ func TestGiteaDownloadRepo(t *testing.T) {
224224
Closed: &closed2,
225225
}, issues[1])
226226

227-
comments, err := downloader.GetComments(4)
227+
comments, _, err := downloader.GetComments(base.GetCommentOptions{
228+
IssueNumber: 4,
229+
})
228230
assert.NoError(t, err)
229231
assert.Len(t, comments, 2)
230232
assert.EqualValues(t, 1598975370, comments[0].Created.Unix())

modules/migrations/github.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,9 @@ func (g *GithubDownloaderV3) getComments(issueNumber int64) ([]*base.Comment, er
535535
}
536536

537537
// GetAllComments returns repository comments according page and perPageSize
538-
func (g *GithubDownloaderV3) GetAllComments(page, perPageSize int) ([]*base.Comment, bool, error) {
538+
func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, bool, error) {
539539
var (
540-
allComments = make([]*base.Comment, 0, perPageSize)
540+
allComments = make([]*base.Comment, 0, perPage)
541541
created = "created"
542542
asc = "asc"
543543
)
@@ -546,7 +546,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPageSize int) ([]*base.Comm
546546
Direction: &asc,
547547
ListOptions: github.ListOptions{
548548
Page: page,
549-
PerPage: perPageSize,
549+
PerPage: perPage,
550550
},
551551
}
552552

@@ -555,6 +555,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPageSize int) ([]*base.Comm
555555
if err != nil {
556556
return nil, false, fmt.Errorf("error while listing repos: %v", err)
557557
}
558+
log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments))
558559
g.rate = &resp.Rate
559560
for _, comment := range comments {
560561
var email string
@@ -599,7 +600,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPageSize int) ([]*base.Comm
599600
})
600601
}
601602

602-
return allComments, len(allComments) < perPageSize, nil
603+
return allComments, len(allComments) < perPage, nil
603604
}
604605

605606
// GetPullRequests returns pull requests according page and perPage
@@ -622,6 +623,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
622623
if err != nil {
623624
return nil, false, fmt.Errorf("error while listing repos: %v", err)
624625
}
626+
log.Trace("Request get pull requests %d/%d, but in fact get %d", perPage, page, len(prs))
625627
g.rate = &resp.Rate
626628
for _, pr := range prs {
627629
var body string

modules/migrations/github_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ func TestGitHubDownloadRepo(t *testing.T) {
240240
}, issues)
241241

242242
// downloader.GetComments()
243-
comments, err := downloader.GetComments(2)
243+
comments, _, err := downloader.GetComments(base.GetCommentOptions{
244+
IssueNumber: 2,
245+
})
244246
assert.NoError(t, err)
245247
assert.Len(t, comments, 2)
246248
assert.EqualValues(t, []*base.Comment{

modules/migrations/gitlab_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ func TestGitlabDownloadRepo(t *testing.T) {
204204
},
205205
}, issues)
206206

207-
comments, err := downloader.GetComments(2)
207+
comments, _, err := downloader.GetComments(base.GetCommentOptions{
208+
IssueNumber: 2,
209+
})
208210
assert.NoError(t, err)
209211
assert.Len(t, comments, 4)
210212
assert.EqualValues(t, []*base.Comment{

modules/migrations/gogs_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ func TestGogsDownloadRepo(t *testing.T) {
103103
}, issues)
104104

105105
// downloader.GetComments()
106-
comments, err := downloader.GetComments(1)
106+
comments, _, err := downloader.GetComments(base.GetCommentOptions{
107+
IssueNumber: 1,
108+
})
107109
assert.NoError(t, err)
108110
assert.Len(t, comments, 1)
109111
assert.EqualValues(t, []*base.Comment{

0 commit comments

Comments
 (0)