summaryrefslogtreecommitdiffstats
path: root/models/pull_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/pull_test.go')
-rw-r--r--models/pull_test.go65
1 files changed, 33 insertions, 32 deletions
diff --git a/models/pull_test.go b/models/pull_test.go
index 07216da324..6543d0ec96 100644
--- a/models/pull_test.go
+++ b/models/pull_test.go
@@ -7,20 +7,21 @@ package models
import (
"testing"
+ "code.gitea.io/gitea/models/db"
"github.com/stretchr/testify/assert"
)
func TestPullRequest_LoadAttributes(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
assert.NoError(t, pr.LoadAttributes())
assert.NotNil(t, pr.Merger)
assert.Equal(t, pr.MergerID, pr.Merger.ID)
}
func TestPullRequest_LoadIssue(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
assert.NoError(t, pr.LoadIssue())
assert.NotNil(t, pr.Issue)
assert.Equal(t, int64(2), pr.Issue.ID)
@@ -30,8 +31,8 @@ func TestPullRequest_LoadIssue(t *testing.T) {
}
func TestPullRequest_LoadBaseRepo(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
assert.NoError(t, pr.LoadBaseRepo())
assert.NotNil(t, pr.BaseRepo)
assert.Equal(t, pr.BaseRepoID, pr.BaseRepo.ID)
@@ -41,8 +42,8 @@ func TestPullRequest_LoadBaseRepo(t *testing.T) {
}
func TestPullRequest_LoadHeadRepo(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
assert.NoError(t, pr.LoadHeadRepo())
assert.NotNil(t, pr.HeadRepo)
assert.Equal(t, pr.HeadRepoID, pr.HeadRepo.ID)
@@ -53,7 +54,7 @@ func TestPullRequest_LoadHeadRepo(t *testing.T) {
// TODO TestNewPullRequest
func TestPullRequestsNewest(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
prs, count, err := PullRequests(1, &PullRequestsOptions{
ListOptions: ListOptions{
Page: 1,
@@ -72,7 +73,7 @@ func TestPullRequestsNewest(t *testing.T) {
}
func TestPullRequestsOldest(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
prs, count, err := PullRequests(1, &PullRequestsOptions{
ListOptions: ListOptions{
Page: 1,
@@ -91,7 +92,7 @@ func TestPullRequestsOldest(t *testing.T) {
}
func TestGetUnmergedPullRequest(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
pr, err := GetUnmergedPullRequest(1, 1, "branch2", "master", PullRequestFlowGithub)
assert.NoError(t, err)
assert.Equal(t, int64(2), pr.ID)
@@ -102,7 +103,7 @@ func TestGetUnmergedPullRequest(t *testing.T) {
}
func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
prs, err := GetUnmergedPullRequestsByHeadInfo(1, "branch2")
assert.NoError(t, err)
assert.Len(t, prs, 1)
@@ -113,7 +114,7 @@ func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) {
}
func TestGetUnmergedPullRequestsByBaseInfo(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
prs, err := GetUnmergedPullRequestsByBaseInfo(1, "master")
assert.NoError(t, err)
assert.Len(t, prs, 1)
@@ -124,7 +125,7 @@ func TestGetUnmergedPullRequestsByBaseInfo(t *testing.T) {
}
func TestGetPullRequestByIndex(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
pr, err := GetPullRequestByIndex(1, 2)
assert.NoError(t, err)
assert.Equal(t, int64(1), pr.BaseRepoID)
@@ -136,7 +137,7 @@ func TestGetPullRequestByIndex(t *testing.T) {
}
func TestGetPullRequestByID(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
pr, err := GetPullRequestByID(1)
assert.NoError(t, err)
assert.Equal(t, int64(1), pr.ID)
@@ -148,7 +149,7 @@ func TestGetPullRequestByID(t *testing.T) {
}
func TestGetPullRequestByIssueID(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
pr, err := GetPullRequestByIssueID(2)
assert.NoError(t, err)
assert.Equal(t, int64(2), pr.IssueID)
@@ -159,20 +160,20 @@ func TestGetPullRequestByIssueID(t *testing.T) {
}
func TestPullRequest_Update(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
pr.BaseBranch = "baseBranch"
pr.HeadBranch = "headBranch"
pr.Update()
- pr = AssertExistsAndLoadBean(t, &PullRequest{ID: pr.ID}).(*PullRequest)
+ pr = db.AssertExistsAndLoadBean(t, &PullRequest{ID: pr.ID}).(*PullRequest)
assert.Equal(t, "baseBranch", pr.BaseBranch)
assert.Equal(t, "headBranch", pr.HeadBranch)
CheckConsistencyFor(t, pr)
}
func TestPullRequest_UpdateCols(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
pr := &PullRequest{
ID: 1,
BaseBranch: "baseBranch",
@@ -180,18 +181,18 @@ func TestPullRequest_UpdateCols(t *testing.T) {
}
assert.NoError(t, pr.UpdateCols("head_branch"))
- pr = AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
+ pr = db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest)
assert.Equal(t, "master", pr.BaseBranch)
assert.Equal(t, "headBranch", pr.HeadBranch)
CheckConsistencyFor(t, pr)
}
func TestPullRequestList_LoadAttributes(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
prs := []*PullRequest{
- AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest),
- AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest),
+ db.AssertExistsAndLoadBean(t, &PullRequest{ID: 1}).(*PullRequest),
+ db.AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest),
}
assert.NoError(t, PullRequestList(prs).LoadAttributes())
for _, pr := range prs {
@@ -205,9 +206,9 @@ func TestPullRequestList_LoadAttributes(t *testing.T) {
// TODO TestAddTestPullRequestTask
func TestPullRequest_IsWorkInProgress(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
pr.LoadIssue()
assert.False(t, pr.IsWorkInProgress())
@@ -220,9 +221,9 @@ func TestPullRequest_IsWorkInProgress(t *testing.T) {
}
func TestPullRequest_GetWorkInProgressPrefixWorkInProgress(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
pr.LoadIssue()
assert.Empty(t, pr.GetWorkInProgressPrefix())
@@ -236,8 +237,8 @@ func TestPullRequest_GetWorkInProgressPrefixWorkInProgress(t *testing.T) {
}
func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
+ assert.NoError(t, db.PrepareTestDatabase())
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 2}).(*PullRequest)
assert.Equal(t, "Merge pull request 'issue3' (#3) from branch2 into master", pr.GetDefaultMergeMessage())
@@ -247,7 +248,7 @@ func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
}
func TestPullRequest_GetDefaultMergeMessage_ExternalTracker(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
+ assert.NoError(t, db.PrepareTestDatabase())
externalTracker := RepoUnit{
Type: UnitTypeExternalTracker,
@@ -259,7 +260,7 @@ func TestPullRequest_GetDefaultMergeMessage_ExternalTracker(t *testing.T) {
baseRepo.Owner = &User{Name: "testOwner"}
baseRepo.Units = []*RepoUnit{&externalTracker}
- pr := AssertExistsAndLoadBean(t, &PullRequest{ID: 2, BaseRepo: baseRepo}).(*PullRequest)
+ pr := db.AssertExistsAndLoadBean(t, &PullRequest{ID: 2, BaseRepo: baseRepo}).(*PullRequest)
assert.Equal(t, "Merge pull request 'issue3' (!3) from branch2 into master", pr.GetDefaultMergeMessage())