forked from go-gomail/gomail
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more details when failing to parse email addresses to make findin…
…g problems with input easier
- Loading branch information
Julius Foitzik
committed
Jul 5, 2021
1 parent
f59b9b8
commit 22eaa21
Showing
2 changed files
with
28 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package mail | |
import ( | ||
"bytes" | ||
"encoding/base64" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"path/filepath" | ||
|
@@ -380,6 +381,26 @@ func TestRename(t *testing.T) { | |
testMessage(t, m, 1, want) | ||
} | ||
|
||
func TestEmptyAddress(t *testing.T) { | ||
cases := []struct { | ||
headerName string | ||
value string | ||
}{ | ||
{headerName: "From", value: ""}, | ||
{headerName: "To", value: ""}, | ||
} | ||
for i, tc := range cases { | ||
t.Run(fmt.Sprintf("case_%d", i), func(t *testing.T) { | ||
m := NewMessage() | ||
m.SetHeader(tc.headerName, tc.value) | ||
err := Send(stubSendMail(t, 1, nil), m) | ||
if err == nil { | ||
t.Error("expected error but got none") | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestAttachmentsOnly(t *testing.T) { | ||
m := NewMessage() | ||
m.SetHeader("From", "[email protected]") | ||
|
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