refactor: decouple context from migration structs (#33399)
Use context as much as possible. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
466cc725bc
commit
1ec8d80fa3
23 changed files with 455 additions and 509 deletions
|
@ -28,9 +28,9 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
t.Skipf("visit test repo failed, ignored")
|
||||
return
|
||||
}
|
||||
|
||||
downloader := NewGogsDownloader(context.Background(), "https://try.gogs.io", "", "", gogsPersonalAccessToken, "lunnytest", "TESTREPO")
|
||||
repo, err := downloader.GetRepoInfo()
|
||||
ctx := context.Background()
|
||||
downloader := NewGogsDownloader(ctx, "https://try.gogs.io", "", "", gogsPersonalAccessToken, "lunnytest", "TESTREPO")
|
||||
repo, err := downloader.GetRepoInfo(ctx)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assertRepositoryEqual(t, &base.Repository{
|
||||
|
@ -42,7 +42,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
DefaultBranch: "master",
|
||||
}, repo)
|
||||
|
||||
milestones, err := downloader.GetMilestones()
|
||||
milestones, err := downloader.GetMilestones(ctx)
|
||||
assert.NoError(t, err)
|
||||
assertMilestonesEqual(t, []*base.Milestone{
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
},
|
||||
}, milestones)
|
||||
|
||||
labels, err := downloader.GetLabels()
|
||||
labels, err := downloader.GetLabels(ctx)
|
||||
assert.NoError(t, err)
|
||||
assertLabelsEqual(t, []*base.Label{
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
}, labels)
|
||||
|
||||
// downloader.GetIssues()
|
||||
issues, isEnd, err := downloader.GetIssues(1, 8)
|
||||
issues, isEnd, err := downloader.GetIssues(ctx, 1, 8)
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, isEnd)
|
||||
assertIssuesEqual(t, []*base.Issue{
|
||||
|
@ -110,7 +110,7 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
}, issues)
|
||||
|
||||
// downloader.GetComments()
|
||||
comments, _, err := downloader.GetComments(&base.Issue{Number: 1, ForeignIndex: 1})
|
||||
comments, _, err := downloader.GetComments(ctx, &base.Issue{Number: 1, ForeignIndex: 1})
|
||||
assert.NoError(t, err)
|
||||
assertCommentsEqual(t, []*base.Comment{
|
||||
{
|
||||
|
@ -134,6 +134,6 @@ func TestGogsDownloadRepo(t *testing.T) {
|
|||
}, comments)
|
||||
|
||||
// downloader.GetPullRequests()
|
||||
_, _, err = downloader.GetPullRequests(1, 3)
|
||||
_, _, err = downloader.GetPullRequests(ctx, 1, 3)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue