-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_entry_test.go
50 lines (34 loc) · 976 Bytes
/
header_entry_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
package gomail
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestNewHeaderEntry(t *testing.T) {
r := require.New(t)
expected := HeaderEntry{
Key: "From",
Value: []string{"[email protected]"},
}
actual, _ := NewHeaderEntry("From", "[email protected]")
r.Equal(expected, actual)
}
func TestNewHeaderEntryInvalidField(t *testing.T) {
r := require.New(t)
_, err := NewHeaderEntry("Asdf", "")
r.EqualError(err, "invalid field name Asdf")
}
func TestNewHeaderEntryMultipleFieldError(t *testing.T) {
r := require.New(t)
_, err := NewHeaderEntry("From", "[email protected], [email protected]")
r.EqualError(err, "only one value allowed for field From (2 values given)")
}
func TestValidField(t *testing.T) {
r := require.New(t)
r.True(validField("From"))
r.False(validField("Asdf"))
}
func TestMultipleFieldsAllowed(t *testing.T) {
r := require.New(t)
r.True(multipleFieldsAllowed("To"))
r.False(multipleFieldsAllowed("From"))
}