forked from domodwyer/mailyak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailyak_test.go
35 lines (29 loc) · 1.27 KB
/
mailyak_test.go
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
package mailyak
import (
"fmt"
"net/smtp"
"strings"
"testing"
)
// TestMailYakStringer ensures MailYak struct conforms to the Stringer interface.
func TestMailYakStringer(t *testing.T) {
t.Parallel()
mail := New("mail.host.com:25", smtp.PlainAuth("", "user", "pass", "mail.host.com"))
mail.From("[email protected]")
mail.FromName("From Example")
mail.To("[email protected]")
mail.Bcc("[email protected]", "[email protected]")
mail.Subject("Test subject")
mail.ReplyTo("[email protected]")
mail.HTML().Set("HTML part: this is just a test.")
mail.Plain().Set("Plain text part: this is also just a test.")
mail.Attach("test.html", strings.NewReader("<html><head></head></html>"))
mail.Attach("test2.html", strings.NewReader("<html><head></head></html>"))
mail.AddHeader("Precedence", "bulk")
mail.date = "a date"
want := "&MailYak{date: \"a date\", from: \"[email protected]\", fromName: \"From Example\", html: 31 bytes, plain: 42 bytes, toAddrs: [[email protected]], bccAddrs: [[email protected] [email protected]], subject: \"Test subject\", Precedence: \"bulk\", host: \"mail.host.com:25\", attachments (2): [{filename: test.html} {filename: test2.html}], auth set: true}"
got := fmt.Sprintf("%+v", mail)
if got != want {
t.Errorf("MailYak.String() = %v, want %v", got, want)
}
}