From e3ed67859a434f2fef1db175e9c82251a7f9f6c9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 9 Sep 2023 05:09:23 +0800 Subject: Move some functions to service layer (#26969) --- models/issues/issue_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'models/issues/issue_test.go') 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) +} -- cgit v1.2.3