-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_test.go
More file actions
58 lines (48 loc) · 1.04 KB
/
Copy pathheader_test.go
File metadata and controls
58 lines (48 loc) · 1.04 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
47
48
49
50
51
52
53
54
55
56
57
58
package easymail
import (
"bytes"
"fmt"
"mime/multipart"
"testing"
"github.com/stretchr/testify/assert"
)
func TestHeaderGetRecipients(t *testing.T) {
var (
h Header
emailTo = "to@test.com"
emailCc = "cc@test.com"
emailBcc = "bcc@test.com"
)
h.To.Append(emailTo)
h.Cc.Append(emailCc)
h.Bcc.Append(emailBcc)
recipients := h.GetRecipients()
expectedEmails := map[string]bool{
emailTo: false,
emailCc: false,
emailBcc: false,
}
for _, v := range recipients {
expectedEmails[v] = true
}
for email, emailExist := range expectedEmails {
if !assert.True(t, emailExist, fmt.Sprintf("not found '%s' email in recippients", email)) {
t.FailNow()
}
}
}
func TestHeaderWrite(t *testing.T) {
var (
h Header
b = bytes.Buffer{}
mpw = multipart.NewWriter(&b)
)
mpw.SetBoundary("test123")
h.write(mpw)
s := b.String()
if !assert.Contains(t, s, "--test123") ||
!assert.Contains(t, s, "Content-Type: multipart/mixed; boundary=\"test123\"") ||
!assert.Contains(t, s, "Mime-Version: 1.0") {
t.FailNow()
}
}