mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	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:
		| @@ -31,12 +31,12 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 	if err != nil || resp.StatusCode != http.StatusOK { | ||||
| 		t.Skipf("Can't access test repo, skipping %s", t.Name()) | ||||
| 	} | ||||
|  | ||||
| 	downloader, err := NewGitlabDownloader(context.Background(), "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken) | ||||
| 	ctx := context.Background() | ||||
| 	downloader, err := NewGitlabDownloader(ctx, "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("NewGitlabDownloader is nil: %v", err) | ||||
| 	} | ||||
| 	repo, err := downloader.GetRepoInfo() | ||||
| 	repo, err := downloader.GetRepoInfo(ctx) | ||||
| 	assert.NoError(t, err) | ||||
| 	// Repo Owner is blank in Gitlab Group repos | ||||
| 	assertRepositoryEqual(t, &base.Repository{ | ||||
| @@ -48,12 +48,12 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		DefaultBranch: "master", | ||||
| 	}, repo) | ||||
|  | ||||
| 	topics, err := downloader.GetTopics() | ||||
| 	topics, err := downloader.GetTopics(ctx) | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.Len(t, topics, 2) | ||||
| 	assert.EqualValues(t, []string{"migration", "test"}, topics) | ||||
|  | ||||
| 	milestones, err := downloader.GetMilestones() | ||||
| 	milestones, err := downloader.GetMilestones(ctx) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertMilestonesEqual(t, []*base.Milestone{ | ||||
| 		{ | ||||
| @@ -71,7 +71,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, milestones) | ||||
|  | ||||
| 	labels, err := downloader.GetLabels() | ||||
| 	labels, err := downloader.GetLabels(ctx) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertLabelsEqual(t, []*base.Label{ | ||||
| 		{ | ||||
| @@ -112,7 +112,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, labels) | ||||
|  | ||||
| 	releases, err := downloader.GetReleases() | ||||
| 	releases, err := downloader.GetReleases(ctx) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertReleasesEqual(t, []*base.Release{ | ||||
| 		{ | ||||
| @@ -126,7 +126,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, releases) | ||||
|  | ||||
| 	issues, isEnd, err := downloader.GetIssues(1, 2) | ||||
| 	issues, isEnd, err := downloader.GetIssues(ctx, 1, 2) | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.False(t, isEnd) | ||||
|  | ||||
| @@ -214,7 +214,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, issues) | ||||
|  | ||||
| 	comments, _, err := downloader.GetComments(&base.Issue{ | ||||
| 	comments, _, err := downloader.GetComments(ctx, &base.Issue{ | ||||
| 		Number:       2, | ||||
| 		ForeignIndex: 2, | ||||
| 		Context:      gitlabIssueContext{IsMergeRequest: false}, | ||||
| @@ -255,7 +255,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, comments) | ||||
|  | ||||
| 	prs, _, err := downloader.GetPullRequests(1, 1) | ||||
| 	prs, _, err := downloader.GetPullRequests(ctx, 1, 1) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertPullRequestsEqual(t, []*base.PullRequest{ | ||||
| 		{ | ||||
| @@ -304,7 +304,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, prs) | ||||
|  | ||||
| 	rvs, err := downloader.GetReviews(&base.PullRequest{Number: 1, ForeignIndex: 1}) | ||||
| 	rvs, err := downloader.GetReviews(ctx, &base.PullRequest{Number: 1, ForeignIndex: 1}) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertReviewsEqual(t, []*base.Review{ | ||||
| 		{ | ||||
| @@ -323,7 +323,7 @@ func TestGitlabDownloadRepo(t *testing.T) { | ||||
| 		}, | ||||
| 	}, rvs) | ||||
|  | ||||
| 	rvs, err = downloader.GetReviews(&base.PullRequest{Number: 2, ForeignIndex: 2}) | ||||
| 	rvs, err = downloader.GetReviews(ctx, &base.PullRequest{Number: 2, ForeignIndex: 2}) | ||||
| 	assert.NoError(t, err) | ||||
| 	assertReviewsEqual(t, []*base.Review{ | ||||
| 		{ | ||||
| @@ -423,9 +423,8 @@ func TestGitlabGetReviews(t *testing.T) { | ||||
| 	defer gitlabClientMockTeardown(server) | ||||
|  | ||||
| 	repoID := 1324 | ||||
|  | ||||
| 	ctx := context.Background() | ||||
| 	downloader := &GitlabDownloader{ | ||||
| 		ctx:    context.Background(), | ||||
| 		client: client, | ||||
| 		repoID: repoID, | ||||
| 	} | ||||
| @@ -465,7 +464,7 @@ func TestGitlabGetReviews(t *testing.T) { | ||||
| 		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(&base.Issue{Number: id, ForeignIndex: id}) | ||||
| 		rvs, err := downloader.GetReviews(ctx, &base.Issue{Number: id, ForeignIndex: id}) | ||||
| 		assert.NoError(t, err) | ||||
| 		assertReviewsEqual(t, []*base.Review{&review}, rvs) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user