-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for multiple values for same header key (#80)
* added support for multiple values for same header key * style: direct err return Fixes a lint failure by returning the err directly, rather than via a conditional. --------- Co-authored-by: Dom Dwyer <[email protected]>
- Loading branch information
1 parent
8cabd8d
commit 87b7a70
Showing
5 changed files
with
53 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ func TestMailYakStringer(t *testing.T) { | |
|
||
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, explicit tls: false}" | ||
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, explicit tls: false}" | ||
got := fmt.Sprintf("%+v", mail) | ||
if got != want { | ||
t.Errorf("MailYak.String() = %v, want %v", got, want) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,28 +256,37 @@ func TestMailYakAddHeader(t *testing.T) { | |
// Test description. | ||
name string | ||
// Parameters. | ||
from map[string]string | ||
from map[string][]string | ||
// Want | ||
want map[string]string | ||
want map[string][]string | ||
}{ | ||
{ | ||
"ASCII", | ||
map[string]string{ | ||
"List-Unsubscribe": "http://example.com", | ||
"X-NASTY": "true\r\nBcc: [email protected]", | ||
map[string][]string{ | ||
"List-Unsubscribe": {"http://example.com"}, | ||
"X-NASTY": {"true\r\nBcc: [email protected]"}, | ||
}, | ||
map[string]string{ | ||
"List-Unsubscribe": "http://example.com", | ||
"X-NASTY": "trueBcc: [email protected]", | ||
map[string][]string{ | ||
"List-Unsubscribe": {"http://example.com"}, | ||
"X-NASTY": {"trueBcc: [email protected]"}, | ||
}, | ||
}, | ||
{ | ||
"Q-encoded", | ||
map[string]string{ | ||
"X-BEETHOVEN": "für Elise", | ||
map[string][]string{ | ||
"X-BEETHOVEN": {"für Elise"}, | ||
}, | ||
map[string]string{ | ||
"X-BEETHOVEN": "=?UTF-8?q?f=C3=BCr_Elise?=", | ||
map[string][]string{ | ||
"X-BEETHOVEN": {"=?UTF-8?q?f=C3=BCr_Elise?="}, | ||
}, | ||
}, | ||
{ | ||
"Multi", | ||
map[string][]string{ | ||
"X-MailGun-Tag": {"marketing", "transactional"}, | ||
}, | ||
map[string][]string{ | ||
"X-MailGun-Tag": {"marketing", "transactional"}, | ||
}, | ||
}, | ||
} | ||
|
@@ -287,12 +296,14 @@ func TestMailYakAddHeader(t *testing.T) { | |
t.Parallel() | ||
|
||
m := &MailYak{ | ||
headers: map[string]string{}, | ||
headers: map[string][]string{}, | ||
trimRegex: regexp.MustCompile("\r?\n"), | ||
} | ||
|
||
for k, v := range tt.from { | ||
m.AddHeader(k, v) | ||
for k, values := range tt.from { | ||
for _, v := range values { | ||
m.AddHeader(k, v) | ||
} | ||
} | ||
|
||
if !reflect.DeepEqual(m.headers, tt.want) { | ||
|
@@ -330,7 +341,7 @@ func TestMailYakLocalName(t *testing.T) { | |
t.Parallel() | ||
|
||
m := &MailYak{ | ||
headers: map[string]string{}, | ||
headers: map[string][]string{}, | ||
trimRegex: regexp.MustCompile("\r?\n"), | ||
} | ||
|
||
|