Skip to content

Commit 962d0c3

Browse files
committed
fix tests
1 parent b4ebba7 commit 962d0c3

File tree

2 files changed

+59
-36
lines changed

2 files changed

+59
-36
lines changed

modules/migrations/github.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
362362

363363
// get reactions
364364
var reactions []*base.Reaction
365-
for i := 0; ; i++ {
365+
for i := 1; ; i++ {
366366
g.sleep()
367367
res, resp, err := g.client.Reactions.ListIssueReactions(g.ctx, g.repoOwner, g.repoName, issue.GetNumber(), &github.ListOptions{
368368
Page: i,
@@ -430,7 +430,7 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
430430

431431
// get reactions
432432
var reactions []*base.Reaction
433-
for i := 0; ; i++ {
433+
for i := 1; ; i++ {
434434
g.sleep()
435435
res, resp, err := g.client.Reactions.ListIssueCommentReactions(g.ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListOptions{
436436
Page: i,
@@ -544,7 +544,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
544544

545545
// get reactions
546546
var reactions []*base.Reaction
547-
for i := 0; ; i++ {
547+
for i := 1; ; i++ {
548548
g.sleep()
549549
res, resp, err := g.client.Reactions.ListIssueReactions(g.ctx, g.repoOwner, g.repoName, pr.GetNumber(), &github.ListOptions{
550550
Page: i,

modules/migrations/github_test.go

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,12 @@ func TestGitHubDownloadRepo(t *testing.T) {
170170
Description: "Good for newcomers",
171171
},
172172
},
173-
Reactions: &base.Reactions{
174-
TotalCount: 1,
175-
PlusOne: 1,
176-
MinusOne: 0,
177-
Laugh: 0,
178-
Confused: 0,
179-
Heart: 0,
180-
Hooray: 0,
173+
Reactions: []*base.Reaction{
174+
{
175+
UserID: 1669571,
176+
UserName: "mrsdizzie",
177+
Content: "+1",
178+
},
181179
},
182180
Closed: &closed1,
183181
},
@@ -198,14 +196,37 @@ func TestGitHubDownloadRepo(t *testing.T) {
198196
Description: "This issue or pull request already exists",
199197
},
200198
},
201-
Reactions: &base.Reactions{
202-
TotalCount: 6,
203-
PlusOne: 1,
204-
MinusOne: 1,
205-
Laugh: 1,
206-
Confused: 1,
207-
Heart: 1,
208-
Hooray: 1,
199+
Reactions: []*base.Reaction{
200+
{
201+
UserID: 1669571,
202+
UserName: "mrsdizzie",
203+
Content: "heart",
204+
},
205+
{
206+
UserID: 1669571,
207+
UserName: "mrsdizzie",
208+
Content: "laugh",
209+
},
210+
{
211+
UserID: 1669571,
212+
UserName: "mrsdizzie",
213+
Content: "confused",
214+
},
215+
{
216+
UserID: 1669571,
217+
UserName: "mrsdizzie",
218+
Content: "hooray",
219+
},
220+
{
221+
UserID: 1669571,
222+
UserName: "mrsdizzie",
223+
Content: "+1",
224+
},
225+
{
226+
UserID: 1669571,
227+
UserName: "mrsdizzie",
228+
Content: "+1",
229+
},
209230
},
210231
Closed: &closed2,
211232
},
@@ -223,14 +244,12 @@ func TestGitHubDownloadRepo(t *testing.T) {
223244
Created: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
224245
Updated: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
225246
Content: "This is a comment",
226-
Reactions: &base.Reactions{
227-
TotalCount: 1,
228-
PlusOne: 1,
229-
MinusOne: 0,
230-
Laugh: 0,
231-
Confused: 0,
232-
Heart: 0,
233-
Hooray: 0,
247+
Reactions: []*base.Reaction{
248+
{
249+
UserID: 1669571,
250+
UserName: "mrsdizzie",
251+
Content: "+1",
252+
},
234253
},
235254
},
236255
{
@@ -240,15 +259,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
240259
Created: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
241260
Updated: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
242261
Content: "A second comment",
243-
Reactions: &base.Reactions{
244-
TotalCount: 0,
245-
PlusOne: 0,
246-
MinusOne: 0,
247-
Laugh: 0,
248-
Confused: 0,
249-
Heart: 0,
250-
Hooray: 0,
251-
},
262+
Reactions: nil,
252263
},
253264
}, comments[:2])
254265

@@ -331,6 +342,18 @@ func TestGitHubDownloadRepo(t *testing.T) {
331342
},
332343
Merged: false,
333344
MergeCommitSHA: "565d1208f5fffdc1c5ae1a2436491eb9a5e4ebae",
345+
Reactions: []*base.Reaction{
346+
{
347+
UserID: 81045,
348+
UserName: "lunny",
349+
Content: "heart",
350+
},
351+
{
352+
UserID: 81045,
353+
UserName: "lunny",
354+
Content: "+1",
355+
},
356+
},
334357
},
335358
}, prs)
336359
}

0 commit comments

Comments
 (0)