This commit is contained in:
Lunny Xiao
2026-05-25 22:20:31 -07:00
parent 7f0d53eb90
commit 8fd9b7a397
7 changed files with 23 additions and 109 deletions
+3 -4
View File
@@ -10,8 +10,7 @@ import (
"strings"
"testing"
teagit "code.gitea.io/tea/modules/git"
git_plumbing "github.com/go-git/go-git/v5/plumbing"
teagit "gitea.dev/tea/modules/git"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -23,7 +22,7 @@ func TestTeaCheckoutRemoteReferenceKeepsWorktreeClean(t *testing.T) {
repo, err := teagit.RepoFromPath(clonePath)
require.NoError(t, err)
err = repo.TeaCheckout(git_plumbing.NewRemoteReferenceName("origin", "feature/test-branch"))
err = repo.TeaCheckout(teagit.NewRemoteReferenceName("origin", "feature/test-branch"))
require.NoError(t, err)
assert.Empty(t, gitOutput(t, clonePath, "status", "--porcelain"))
@@ -40,7 +39,7 @@ func TestTeaCreateBranchTracksRemoteBranch(t *testing.T) {
err = repo.TeaCreateBranch("pulls/123", "feature/test-branch", "origin")
require.NoError(t, err)
err = repo.TeaCheckout(git_plumbing.NewBranchReferenceName("pulls/123"))
err = repo.TeaCheckout(teagit.NewBranchReferenceName("pulls/123"))
require.NoError(t, err)
assert.Empty(t, gitOutput(t, clonePath, "status", "--porcelain"))
+10 -9
View File
@@ -12,8 +12,9 @@ import (
"testing"
"time"
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/cmd/pulls"
"gitea.dev/tea/cmd/pulls"
gitea "gitea.dev/sdk"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v3"
)
@@ -26,14 +27,14 @@ func TestPullsReply(t *testing.T) {
featureBranch := fmt.Sprintf("reply-test-%d", timestamp)
replyBody := fmt.Sprintf("Thanks for the review %d", timestamp)
repo, _, err := client.CreateRepo(gitea.CreateRepoOption{
repo, _, err := client.Repositories.CreateRepo(t.Context(), gitea.CreateRepoOption{
Name: repoName,
AutoInit: true,
DefaultBranch: "main",
})
require.NoError(t, err)
t.Cleanup(func() {
if _, delErr := client.DeleteRepo(login.User, repoName); delErr != nil {
if _, delErr := client.Repositories.DeleteRepo(t.Context(), login.User, repoName); delErr != nil {
t.Logf("failed to delete integration test repo %q: %v", repoName, delErr)
}
})
@@ -43,7 +44,7 @@ func TestPullsReply(t *testing.T) {
baseBranch = "main"
}
_, _, err = client.CreateFile(login.User, repoName, "review.txt", gitea.CreateFileOptions{
_, _, err = client.Repositories.CreateFile(t.Context(), login.User, repoName, "review.txt", gitea.CreateFileOptions{
FileOptions: gitea.FileOptions{
Message: "add review target",
BranchName: baseBranch,
@@ -53,7 +54,7 @@ func TestPullsReply(t *testing.T) {
})
require.NoError(t, err)
pr, _, err := client.CreatePullRequest(login.User, repoName, gitea.CreatePullRequestOption{
pr, _, err := client.PullRequests.CreatePullRequest(t.Context(), login.User, repoName, gitea.CreatePullRequestOption{
Base: baseBranch,
Head: featureBranch,
Title: "Integration test for pr reply",
@@ -61,7 +62,7 @@ func TestPullsReply(t *testing.T) {
})
require.NoError(t, err)
review, _, err := client.CreatePullReview(login.User, repoName, pr.Index, gitea.CreatePullReviewOptions{
review, _, err := client.PullRequests.CreatePullReview(t.Context(), login.User, repoName, pr.Index, gitea.CreatePullReviewOptions{
State: gitea.ReviewStateComment,
Body: "Please take another look.",
Comments: []gitea.CreatePullReviewComment{{
@@ -72,7 +73,7 @@ func TestPullsReply(t *testing.T) {
})
require.NoError(t, err)
comments, _, err := client.ListPullReviewComments(login.User, repoName, pr.Index, review.ID)
comments, _, err := client.PullRequests.ListPullReviewComments(t.Context(), login.User, repoName, pr.Index, review.ID)
require.NoError(t, err)
require.Len(t, comments, 1)
@@ -98,7 +99,7 @@ func TestPullsReply(t *testing.T) {
require.NoError(t, err)
require.Eventually(t, func() bool {
reviewComments, _, listErr := client.ListPullReviewComments(login.User, repoName, pr.Index, review.ID)
reviewComments, _, listErr := client.PullRequests.ListPullReviewComments(t.Context(), login.User, repoName, pr.Index, review.ID)
if listErr != nil {
t.Logf("failed to list review comments: %v", listErr)
return false