@@ -67,9 +67,8 @@ func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *repo_model.Re
6767func TestComposeIssueCommentMessage (t * testing.T ) {
6868 doer , _ , issue , comment := prepareMailerTest (t )
6969
70- stpl := texttmpl .Must (texttmpl .New ("issue/comment" ).Parse (subjectTpl ))
71- btpl := template .Must (template .New ("issue/comment" ).Parse (bodyTpl ))
72- InitMailRender (stpl , btpl )
70+ subjectTemplates = texttmpl .Must (texttmpl .New ("issue/comment" ).Parse (subjectTpl ))
71+ bodyTemplates = template .Must (template .New ("issue/comment" ).Parse (bodyTpl ))
7372
7473 recipients := []
* user_model.
User {{
Name :
"Test" ,
Email :
"[email protected] " }, {
Name :
"Test2" ,
Email :
"[email protected] " }}
7574 msgs , err := composeIssueCommentMessages (& mailCommentContext {
@@ -97,9 +96,8 @@ func TestComposeIssueCommentMessage(t *testing.T) {
9796func TestComposeIssueMessage (t * testing.T ) {
9897 doer , _ , issue , _ := prepareMailerTest (t )
9998
100- stpl := texttmpl .Must (texttmpl .New ("issue/new" ).Parse (subjectTpl ))
101- btpl := template .Must (template .New ("issue/new" ).Parse (bodyTpl ))
102- InitMailRender (stpl , btpl )
99+ subjectTemplates = texttmpl .Must (texttmpl .New ("issue/new" ).Parse (subjectTpl ))
100+ bodyTemplates = template .Must (template .New ("issue/new" ).Parse (bodyTpl ))
103101
104102 recipients := []
* user_model.
User {{
Name :
"Test" ,
Email :
"[email protected] " }, {
Name :
"Test2" ,
Email :
"[email protected] " }}
105103 msgs , err := composeIssueCommentMessages (& mailCommentContext {
@@ -128,17 +126,15 @@ func TestTemplateSelection(t *testing.T) {
128126 doer , repo , issue , comment := prepareMailerTest (t )
129127 recipients := []
* user_model.
User {{
Name :
"Test" ,
Email :
"[email protected] " }}
130128
131- stpl : = texttmpl .Must (texttmpl .New ("issue/default" ).Parse ("issue/default/subject" ))
132- texttmpl .Must (stpl .New ("issue/new" ).Parse ("issue/new/subject" ))
133- texttmpl .Must (stpl .New ("pull/comment" ).Parse ("pull/comment/subject" ))
134- texttmpl .Must (stpl .New ("issue/close" ).Parse ("" )) // Must default to fallback subject
129+ subjectTemplates = texttmpl .Must (texttmpl .New ("issue/default" ).Parse ("issue/default/subject" ))
130+ texttmpl .Must (subjectTemplates .New ("issue/new" ).Parse ("issue/new/subject" ))
131+ texttmpl .Must (subjectTemplates .New ("pull/comment" ).Parse ("pull/comment/subject" ))
132+ texttmpl .Must (subjectTemplates .New ("issue/close" ).Parse ("" )) // Must default to fallback subject
135133
136- btpl := template .Must (template .New ("issue/default" ).Parse ("issue/default/body" ))
137- template .Must (btpl .New ("issue/new" ).Parse ("issue/new/body" ))
138- template .Must (btpl .New ("pull/comment" ).Parse ("pull/comment/body" ))
139- template .Must (btpl .New ("issue/close" ).Parse ("issue/close/body" ))
140-
141- InitMailRender (stpl , btpl )
134+ bodyTemplates = template .Must (template .New ("issue/default" ).Parse ("issue/default/body" ))
135+ template .Must (bodyTemplates .New ("issue/new" ).Parse ("issue/new/body" ))
136+ template .Must (bodyTemplates .New ("pull/comment" ).Parse ("pull/comment/body" ))
137+ template .Must (bodyTemplates .New ("issue/close" ).Parse ("issue/close/body" ))
142138
143139 expect := func (t * testing.T , msg * Message , expSubject , expBody string ) {
144140 subject := msg .ToMessage ().GetHeader ("Subject" )
@@ -187,9 +183,8 @@ func TestTemplateServices(t *testing.T) {
187183 expect := func (t * testing.T , issue * issues_model.Issue , comment * issues_model.Comment , doer * user_model.User ,
188184 actionType models.ActionType , fromMention bool , tplSubject , tplBody , expSubject , expBody string ,
189185 ) {
190- stpl := texttmpl .Must (texttmpl .New ("issue/default" ).Parse (tplSubject ))
191- btpl := template .Must (template .New ("issue/default" ).Parse (tplBody ))
192- InitMailRender (stpl , btpl )
186+ subjectTemplates = texttmpl .Must (texttmpl .New ("issue/default" ).Parse (tplSubject ))
187+ bodyTemplates = template .Must (template .New ("issue/default" ).Parse (tplBody ))
193188
194189 recipients := []
* user_model.
User {{
Name :
"Test" ,
Email :
"[email protected] " }}
195190 msg := testComposeIssueCommentMessage (t , & mailCommentContext {
0 commit comments