aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/issue_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-09-09 05:09:23 +0800
committerGitHub <noreply@github.com>2023-09-08 21:09:23 +0000
commite3ed67859a434f2fef1db175e9c82251a7f9f6c9 (patch)
treee4c48b0c17d6d5a9507c3fc1479d7da2faba59dd /models/issues/issue_test.go
parentb8ad558c93052ee3e2f43f1e24e6f5c134da36c4 (diff)
downloadgitea-e3ed67859a434f2fef1db175e9c82251a7f9f6c9.tar.gz
gitea-e3ed67859a434f2fef1db175e9c82251a7f9f6c9.zip
Move some functions to service layer (#26969)
Diffstat (limited to 'models/issues/issue_test.go')
-rw-r--r--models/issues/issue_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/models/issues/issue_test.go b/models/issues/issue_test.go
index 0f2ceadc6b..f1bccc0cf8 100644
--- a/models/issues/issue_test.go
+++ b/models/issues/issue_test.go
@@ -573,3 +573,45 @@ func TestIssueLoadAttributes(t *testing.T) {
}
}
}
+
+func assertCreateIssues(t *testing.T, isPull bool) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+ reponame := "repo1"
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: reponame})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
+ label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
+ milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
+ assert.EqualValues(t, milestone.ID, 1)
+ reaction := &issues_model.Reaction{
+ Type: "heart",
+ UserID: owner.ID,
+ }
+
+ title := "issuetitle1"
+ is := &issues_model.Issue{
+ RepoID: repo.ID,
+ MilestoneID: milestone.ID,
+ Repo: repo,
+ Title: title,
+ Content: "issuecontent1",
+ IsPull: isPull,
+ PosterID: owner.ID,
+ Poster: owner,
+ IsClosed: true,
+ Labels: []*issues_model.Label{label},
+ Reactions: []*issues_model.Reaction{reaction},
+ }
+ err := issues_model.InsertIssues(is)
+ assert.NoError(t, err)
+
+ i := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{Title: title})
+ unittest.AssertExistsAndLoadBean(t, &issues_model.Reaction{Type: "heart", UserID: owner.ID, IssueID: i.ID})
+}
+
+func TestMigrate_CreateIssuesIsPullFalse(t *testing.T) {
+ assertCreateIssues(t, false)
+}
+
+func TestMigrate_CreateIssuesIsPullTrue(t *testing.T) {
+ assertCreateIssues(t, true)
+}