@ -67,9 +67,8 @@ func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *repo_model.Re
func TestComposeIssueCommentMessage ( t * testing . T ) {
func TestComposeIssueCommentMessage ( t * testing . T ) {
doer , _ , issue , comment := prepareMailerTest ( t )
doer , _ , issue , comment := prepareMailerTest ( t )
stpl := texttmpl . Must ( texttmpl . New ( "issue/comment" ) . Parse ( subjectTpl ) )
subjectTemplates = texttmpl . Must ( texttmpl . New ( "issue/comment" ) . Parse ( subjectTpl ) )
btpl := template . Must ( template . New ( "issue/comment" ) . Parse ( bodyTpl ) )
bodyTemplates = template . Must ( template . New ( "issue/comment" ) . Parse ( bodyTpl ) )
InitMailRender ( stpl , btpl )
recipients := [ ] * user_model . 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 {
msgs , err := composeIssueCommentMessages ( & mailCommentContext {
@ -97,9 +96,8 @@ func TestComposeIssueCommentMessage(t *testing.T) {
func TestComposeIssueMessage ( t * testing . T ) {
func TestComposeIssueMessage ( t * testing . T ) {
doer , _ , issue , _ := prepareMailerTest ( t )
doer , _ , issue , _ := prepareMailerTest ( t )
stpl := texttmpl . Must ( texttmpl . New ( "issue/new" ) . Parse ( subjectTpl ) )
subjectTemplates = texttmpl . Must ( texttmpl . New ( "issue/new" ) . Parse ( subjectTpl ) )
btpl := template . Must ( template . New ( "issue/new" ) . Parse ( bodyTpl ) )
bodyTemplates = template . Must ( template . New ( "issue/new" ) . Parse ( bodyTpl ) )
InitMailRender ( stpl , btpl )
recipients := [ ] * user_model . 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 {
msgs , err := composeIssueCommentMessages ( & mailCommentContext {
@ -128,17 +126,15 @@ func TestTemplateSelection(t *testing.T) {
doer , repo , issue , comment := prepareMailerTest ( t )
doer , repo , issue , comment := prepareMailerTest ( t )
recipients := [ ] * user_model . 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" ) )
subjectTemplates = texttmpl . Must ( texttmpl . New ( "issue/default" ) . Parse ( "issue/default/subject" ) )
texttmpl . Must ( stpl . New ( "issue/new" ) . Parse ( "issue/new/subject" ) )
texttmpl . Must ( subjec tTem plates . New ( "issue/new" ) . Parse ( "issue/new/subject" ) )
texttmpl . Must ( stpl . New ( "pull/comment" ) . Parse ( "pull/comment/subject" ) )
texttmpl . Must ( subjec tTem plates . New ( "pull/comment" ) . Parse ( "pull/comment/subject" ) )
texttmpl . Must ( stpl . New ( "issue/close" ) . Parse ( "" ) ) // Must default to fallback subject
texttmpl . Must ( subjec tTem plates . New ( "issue/close" ) . Parse ( "" ) ) // Must default to fallback subject
btpl := template . Must ( template . New ( "issue/default" ) . Parse ( "issue/default/body" ) )
bodyTemplates = template . Must ( template . New ( "issue/default" ) . Parse ( "issue/default/body" ) )
template . Must ( btpl . New ( "issue/new" ) . Parse ( "issue/new/body" ) )
template . Must ( bodyTemplates . New ( "issue/new" ) . Parse ( "issue/new/body" ) )
template . Must ( btpl . New ( "pull/comment" ) . Parse ( "pull/comment/body" ) )
template . Must ( bodyTemplates . New ( "pull/comment" ) . Parse ( "pull/comment/body" ) )
template . Must ( btpl . New ( "issue/close" ) . Parse ( "issue/close/body" ) )
template . Must ( bodyTemplates . New ( "issue/close" ) . Parse ( "issue/close/body" ) )
InitMailRender ( stpl , btpl )
expect := func ( t * testing . T , msg * Message , expSubject , expBody string ) {
expect := func ( t * testing . T , msg * Message , expSubject , expBody string ) {
subject := msg . ToMessage ( ) . GetHeader ( "Subject" )
subject := msg . ToMessage ( ) . GetHeader ( "Subject" )
@ -187,9 +183,8 @@ func TestTemplateServices(t *testing.T) {
expect := func ( t * testing . T , issue * issues_model . Issue , comment * issues_model . Comment , doer * user_model . User ,
expect := func ( t * testing . T , issue * issues_model . Issue , comment * issues_model . Comment , doer * user_model . User ,
actionType models . ActionType , fromMention bool , tplSubject , tplBody , expSubject , expBody string ,
actionType models . ActionType , fromMention bool , tplSubject , tplBody , expSubject , expBody string ,
) {
) {
stpl := texttmpl . Must ( texttmpl . New ( "issue/default" ) . Parse ( tplSubject ) )
subjectTemplates = texttmpl . Must ( texttmpl . New ( "issue/default" ) . Parse ( tplSubject ) )
btpl := template . Must ( template . New ( "issue/default" ) . Parse ( tplBody ) )
bodyTemplates = template . Must ( template . New ( "issue/default" ) . Parse ( tplBody ) )
InitMailRender ( stpl , btpl )
recipients := [ ] * user_model . User { { Name : "Test" , Email : "test@gitea.com" } }
recipients := [ ] * user_model . User { { Name : "Test" , Email : "test@gitea.com" } }
msg := testComposeIssueCommentMessage ( t , & mailCommentContext {
msg := testComposeIssueCommentMessage ( t , & mailCommentContext {