chore: add extra integration test

This commit is contained in:
Gusted 2024-11-09 00:48:49 +01:00
parent 2efc1f5686
commit 536e1923b4
No known key found for this signature in database
GPG Key ID: FD821B732837125F

View File

@ -6,6 +6,7 @@ package integration
import (
"context"
"fmt"
"net/http"
"net/url"
"os"
"path"
@ -136,5 +137,27 @@ func TestCodeOwner(t *testing.T) {
unittest.AssertExistsIf(t, true, &issues_model.Review{IssueID: pr.IssueID, Type: issues_model.ReviewTypeRequest, ReviewerID: 4})
unittest.AssertExistsIf(t, false, &issues_model.Review{IssueID: pr.IssueID, Type: issues_model.ReviewTypeRequest, ReviewerID: 5})
})
t.Run("From a forked repository", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
session := loginUser(t, "user1")
r := fmt.Sprintf("%suser1/repo1.git", u.String())
remoteURL, _ := url.Parse(r)
remoteURL.User = url.UserPassword("user1", userPassword)
doGitAddRemote(dstPath, "forked-2", remoteURL)(t)
err := git.NewCommand(git.DefaultContext, "push", "forked-2", "HEAD:branch").Run(&git.RunOpts{Dir: dstPath})
require.NoError(t, err)
req := NewRequestWithValues(t, "POST", repo.FullName()+"/compare/main...user1/repo1:branch", map[string]string{
"_csrf": GetCSRF(t, session, repo.FullName()+"/compare/main...user1/repo1:branch"),
"title": "pull request",
})
session.MakeRequest(t, req, http.StatusOK)
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: repo.ID, HeadBranch: "branch"})
unittest.AssertExistsIf(t, true, &issues_model.Review{IssueID: pr.IssueID, Type: issues_model.ReviewTypeRequest, ReviewerID: 4})
})
})
}