diff options
Diffstat (limited to 'services/mailer/mail_test.go')
-rw-r--r-- | services/mailer/mail_test.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/services/mailer/mail_test.go b/services/mailer/mail_test.go index 94ff5a65ae..8e8cd98231 100644 --- a/services/mailer/mail_test.go +++ b/services/mailer/mail_test.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/setting" "github.com/stretchr/testify/assert" @@ -40,7 +41,7 @@ const bodyTpl = ` </html> ` -func prepareMailerTest(t *testing.T) (doer *models.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) { +func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) { assert.NoError(t, unittest.PrepareTestDatabase()) var mailService = setting.Mailer{ From: "test@gitea.com", @@ -49,7 +50,7 @@ func prepareMailerTest(t *testing.T) (doer *models.User, repo *models.Repository setting.MailService = &mailService setting.Domain = "localhost" - doer = unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + doer = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) repo = unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1, Owner: doer}).(*models.Repository) issue = unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1, Repo: repo, Poster: doer}).(*models.Issue) assert.NoError(t, issue.LoadRepo()) @@ -64,7 +65,7 @@ func TestComposeIssueCommentMessage(t *testing.T) { btpl := template.Must(template.New("issue/comment").Parse(bodyTpl)) InitMailRender(stpl, btpl) - recipients := []*models.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}} + recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}} msgs, err := composeIssueCommentMessages(&mailCommentContext{Issue: issue, Doer: doer, ActionType: models.ActionCommentIssue, Content: "test body", Comment: comment}, "en-US", recipients, false, "issue comment") assert.NoError(t, err) @@ -91,7 +92,7 @@ func TestComposeIssueMessage(t *testing.T) { btpl := template.Must(template.New("issue/new").Parse(bodyTpl)) InitMailRender(stpl, btpl) - recipients := []*models.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}} + recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}, {Name: "Test2", Email: "test2@gitea.com"}} msgs, err := composeIssueCommentMessages(&mailCommentContext{Issue: issue, Doer: doer, ActionType: models.ActionCreateIssue, Content: "test body"}, "en-US", recipients, false, "issue create") assert.NoError(t, err) @@ -113,7 +114,7 @@ func TestComposeIssueMessage(t *testing.T) { func TestTemplateSelection(t *testing.T) { doer, repo, issue, comment := prepareMailerTest(t) - recipients := []*models.User{{Name: "Test", Email: "test@gitea.com"}} + recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}} stpl := texttmpl.Must(texttmpl.New("issue/default").Parse("issue/default/subject")) texttmpl.Must(stpl.New("issue/new").Parse("issue/new/subject")) @@ -159,14 +160,14 @@ func TestTemplateServices(t *testing.T) { doer, _, issue, comment := prepareMailerTest(t) assert.NoError(t, issue.LoadRepo()) - expect := func(t *testing.T, issue *models.Issue, comment *models.Comment, doer *models.User, + expect := func(t *testing.T, issue *models.Issue, comment *models.Comment, doer *user_model.User, actionType models.ActionType, fromMention bool, tplSubject, tplBody, expSubject, expBody string) { stpl := texttmpl.Must(texttmpl.New("issue/default").Parse(tplSubject)) btpl := template.Must(template.New("issue/default").Parse(tplBody)) InitMailRender(stpl, btpl) - recipients := []*models.User{{Name: "Test", Email: "test@gitea.com"}} + recipients := []*user_model.User{{Name: "Test", Email: "test@gitea.com"}} msg := testComposeIssueCommentMessage(t, &mailCommentContext{Issue: issue, Doer: doer, ActionType: actionType, Content: "test body", Comment: comment}, recipients, fromMention, "TestTemplateServices") @@ -198,7 +199,7 @@ func TestTemplateServices(t *testing.T) { "//Re: //") } -func testComposeIssueCommentMessage(t *testing.T, ctx *mailCommentContext, recipients []*models.User, fromMention bool, info string) *Message { +func testComposeIssueCommentMessage(t *testing.T, ctx *mailCommentContext, recipients []*user_model.User, fromMention bool, info string) *Message { msgs, err := composeIssueCommentMessages(ctx, "en-US", recipients, fromMention, info) assert.NoError(t, err) assert.Len(t, msgs, 1) @@ -209,7 +210,7 @@ func TestGenerateAdditionalHeaders(t *testing.T) { doer, _, issue, _ := prepareMailerTest(t) ctx := &mailCommentContext{Issue: issue, Doer: doer} - recipient := &models.User{Name: "Test", Email: "test@gitea.com"} + recipient := &user_model.User{Name: "Test", Email: "test@gitea.com"} headers := generateAdditionalHeaders(ctx, "dummy-reason", recipient) |