forked from nikoksr/notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail_test.go
52 lines (38 loc) · 1018 Bytes
/
mail_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mail
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMail_newEmailHtml(t *testing.T) {
t.Parallel()
text := "test"
m := New("foo", "server")
email := m.newEmail("test", text)
assert.False(t, m.usePlainText)
assert.Equal(t, []byte(nil), email.Text)
assert.Equal(t, []byte(text), email.HTML)
}
func TestMail_newEmailText(t *testing.T) {
t.Parallel()
text := "test"
m := New("foo", "server")
m.BodyFormat(PlainText)
email := m.newEmail("test", text)
assert.True(t, m.usePlainText)
assert.Equal(t, []byte(text), email.Text)
assert.Equal(t, []byte(nil), email.HTML)
}
func TestMail_AddReceivers(t *testing.T) {
t.Parallel()
m := New("foo", "server")
m.AddReceivers("test")
assert.Len(t, m.receiverAddresses, 1)
assert.Equal(t, "test", m.receiverAddresses[0])
}
func TestMail_AuthenticateSMTP(t *testing.T) {
t.Parallel()
m := New("foo", "server")
assert.Nil(t, m.smtpAuth)
m.AuthenticateSMTP("test", "test", "test", "test")
assert.NotNil(t, m.smtpAuth)
}