@ -6,6 +6,7 @@ package mailer
import (
"bytes"
"context"
"fmt"
"html/template"
"strings"
@ -70,6 +71,7 @@ func TestComposeIssueCommentMessage(t *testing.T) {
recipients := [ ] * user_model . User { { Name : "Test" , Email : "test@gitea.com" } , { Name : "Test2" , Email : "test2@gitea.com" } }
msgs , err := composeIssueCommentMessages ( & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : models . ActionCommentIssue ,
Content : "test body" , Comment : comment ,
} , "en-US" , recipients , false , "issue comment" )
@ -99,6 +101,7 @@ func TestComposeIssueMessage(t *testing.T) {
recipients := [ ] * user_model . User { { Name : "Test" , Email : "test@gitea.com" } , { Name : "Test2" , Email : "test2@gitea.com" } }
msgs , err := composeIssueCommentMessages ( & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : models . ActionCreateIssue ,
Content : "test body" ,
} , "en-US" , recipients , false , "issue create" )
@ -145,12 +148,14 @@ func TestTemplateSelection(t *testing.T) {
}
msg := testComposeIssueCommentMessage ( t , & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : models . ActionCreateIssue ,
Content : "test body" ,
} , recipients , false , "TestTemplateSelection" )
expect ( t , msg , "issue/new/subject" , "issue/new/body" )
msg = testComposeIssueCommentMessage ( t , & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : models . ActionCommentIssue ,
Content : "test body" , Comment : comment ,
} , recipients , false , "TestTemplateSelection" )
@ -159,12 +164,14 @@ func TestTemplateSelection(t *testing.T) {
pull := unittest . AssertExistsAndLoadBean ( t , & models . Issue { ID : 2 , Repo : repo , Poster : doer } ) . ( * models . Issue )
comment = unittest . AssertExistsAndLoadBean ( t , & models . Comment { ID : 4 , Issue : pull } ) . ( * models . Comment )
msg = testComposeIssueCommentMessage ( t , & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : pull , Doer : doer , ActionType : models . ActionCommentPull ,
Content : "test body" , Comment : comment ,
} , recipients , false , "TestTemplateSelection" )
expect ( t , msg , "pull/comment/subject" , "pull/comment/body" )
msg = testComposeIssueCommentMessage ( t , & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : models . ActionCloseIssue ,
Content : "test body" , Comment : comment ,
} , recipients , false , "TestTemplateSelection" )
@ -184,6 +191,7 @@ func TestTemplateServices(t *testing.T) {
recipients := [ ] * user_model . User { { Name : "Test" , Email : "test@gitea.com" } }
msg := testComposeIssueCommentMessage ( t , & mailCommentContext {
Context : context . TODO ( ) , // TODO: use a correct context
Issue : issue , Doer : doer , ActionType : actionType ,
Content : "test body" , Comment : comment ,
} , recipients , fromMention , "TestTemplateServices" )
@ -226,7 +234,7 @@ func testComposeIssueCommentMessage(t *testing.T, ctx *mailCommentContext, recip
func TestGenerateAdditionalHeaders ( t * testing . T ) {
doer , _ , issue , _ := prepareMailerTest ( t )
ctx := & mailCommentContext { Issue : issue , Doer : doer }
ctx := & mailCommentContext { Context : context . TODO ( ) /* TODO: use a correct context */ , Issue : issue , Doer : doer }
recipient := & user_model . User { Name : "Test" , Email : "test@gitea.com" }
headers := generateAdditionalHeaders ( ctx , "dummy-reason" , recipient )