summaryrefslogtreecommitdiffstats
path: root/integrations/pull_merge_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /integrations/pull_merge_test.go
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'integrations/pull_merge_test.go')
-rw-r--r--integrations/pull_merge_test.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go
index 2e219dcc91..812b5dd171 100644
--- a/integrations/pull_merge_test.go
+++ b/integrations/pull_merge_test.go
@@ -17,6 +17,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
@@ -29,7 +30,7 @@ import (
"github.com/unknwon/i18n"
)
-func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string, mergeStyle models.MergeStyle) *httptest.ResponseRecorder {
+func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string, mergeStyle repo_model.MergeStyle) *httptest.ResponseRecorder {
req := NewRequest(t, "GET", path.Join(user, repo, "pulls", pullnum))
resp := session.MakeRequest(t, req, http.StatusOK)
@@ -76,7 +77,7 @@ func TestPullMerge(t *testing.T) {
elem := strings.Split(test.RedirectURL(resp), "/")
assert.EqualValues(t, "pulls", elem[3])
- testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleMerge)
+ testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge)
hookTasks, err = webhook.HookTasks(1, 1)
assert.NoError(t, err)
@@ -98,7 +99,7 @@ func TestPullRebase(t *testing.T) {
elem := strings.Split(test.RedirectURL(resp), "/")
assert.EqualValues(t, "pulls", elem[3])
- testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleRebase)
+ testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebase)
hookTasks, err = webhook.HookTasks(1, 1)
assert.NoError(t, err)
@@ -120,7 +121,7 @@ func TestPullRebaseMerge(t *testing.T) {
elem := strings.Split(test.RedirectURL(resp), "/")
assert.EqualValues(t, "pulls", elem[3])
- testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleRebaseMerge)
+ testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebaseMerge)
hookTasks, err = webhook.HookTasks(1, 1)
assert.NoError(t, err)
@@ -143,7 +144,7 @@ func TestPullSquash(t *testing.T) {
elem := strings.Split(test.RedirectURL(resp), "/")
assert.EqualValues(t, "pulls", elem[3])
- testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleSquash)
+ testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash)
hookTasks, err = webhook.HookTasks(1, 1)
assert.NoError(t, err)
@@ -161,7 +162,7 @@ func TestPullCleanUpAfterMerge(t *testing.T) {
elem := strings.Split(test.RedirectURL(resp), "/")
assert.EqualValues(t, "pulls", elem[3])
- testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleMerge)
+ testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge)
// Check PR branch deletion
resp = testPullCleanUp(t, session, elem[1], elem[2], elem[4])
@@ -225,10 +226,10 @@ func TestCantMergeConflict(t *testing.T) {
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{
Name: "user1",
}).(*user_model.User)
- repo1 := unittest.AssertExistsAndLoadBean(t, &models.Repository{
+ repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
OwnerID: user1.ID,
Name: "repo1",
- }).(*models.Repository)
+ }).(*repo_model.Repository)
pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{
HeadRepoID: repo1.ID,
@@ -237,14 +238,14 @@ func TestCantMergeConflict(t *testing.T) {
BaseBranch: "base",
}).(*models.PullRequest)
- gitRepo, err := git.OpenRepository(models.RepoPath(user1.Name, repo1.Name))
+ gitRepo, err := git.OpenRepository(repo_model.RepoPath(user1.Name, repo1.Name))
assert.NoError(t, err)
- err = pull.Merge(pr, user1, gitRepo, models.MergeStyleMerge, "CONFLICT")
+ err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "CONFLICT")
assert.Error(t, err, "Merge should return an error due to conflict")
assert.True(t, models.IsErrMergeConflicts(err), "Merge error is not a conflict error")
- err = pull.Merge(pr, user1, gitRepo, models.MergeStyleRebase, "CONFLICT")
+ err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleRebase, "CONFLICT")
assert.Error(t, err, "Merge should return an error due to conflict")
assert.True(t, models.IsErrRebaseConflicts(err), "Merge error is not a conflict error")
gitRepo.Close()
@@ -262,11 +263,11 @@ func TestCantMergeUnrelated(t *testing.T) {
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{
Name: "user1",
}).(*user_model.User)
- repo1 := unittest.AssertExistsAndLoadBean(t, &models.Repository{
+ repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
OwnerID: user1.ID,
Name: "repo1",
- }).(*models.Repository)
- path := models.RepoPath(user1.Name, repo1.Name)
+ }).(*repo_model.Repository)
+ path := repo_model.RepoPath(user1.Name, repo1.Name)
_, err := git.NewCommand("read-tree", "--empty").RunInDir(path)
assert.NoError(t, err)
@@ -328,7 +329,7 @@ func TestCantMergeUnrelated(t *testing.T) {
BaseBranch: "base",
}).(*models.PullRequest)
- err = pull.Merge(pr, user1, gitRepo, models.MergeStyleMerge, "UNRELATED")
+ err = pull.Merge(pr, user1, gitRepo, repo_model.MergeStyleMerge, "UNRELATED")
assert.Error(t, err, "Merge should return an error due to unrelated")
assert.True(t, models.IsErrMergeUnrelatedHistories(err), "Merge error is not a unrelated histories error")
gitRepo.Close()