-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmail_test.go
More file actions
46 lines (40 loc) · 1.01 KB
/
mail_test.go
File metadata and controls
46 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2012 GAEGo Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mail
import (
"appengine/mail"
"testing"
)
var (
sender string = "Company Name <noreply@example.com>"
subject string = "Example Subject"
to []string = []string{"1@example.com"}
)
func TestTemplateMessage(t *testing.T) {
v := map[string]string{
"one": "one",
}
bptxt := "templates/test/01.txt"
bphtml := "templates/test/01.html"
msg := &TemplateMessage{
Message: &mail.Message{
Sender: sender,
To: to,
Subject: subject,
},
BodyValues: v,
BodyTmplPath: bptxt,
HTMLBodyTmplPath: bphtml,
}
err := msg.Execute()
if err != nil {
t.Errorf(`err: %v, want "%v"`, err, nil)
}
if b, h := string(msg.Body), string("one == one\n"); b != h {
t.Errorf(`msg.Body: %q, want %q`, b, h)
}
if b, h := string(msg.HTMLBody), string("<h1>one == one</h1>\n"); b != h {
t.Errorf(`msg.Body: %q, want %q`, b, h)
}
}