-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from tariq1890/rfc822-email
Allows users to submit rfc822 formatted email addresses
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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 |
---|---|---|
|
@@ -726,3 +726,25 @@ func TestV3NewSandboxModeSetting(t *testing.T) { | |
assert.True(t, *s.ForwardSpam, "ForwardSpam should be enabled") | ||
assert.NotNil(t, s.SpamCheck, "SpamCheck should not be nil") | ||
} | ||
|
||
func TestParseEmail(t *testing.T) { | ||
e, err := ParseEmail("example example <[email protected]>") | ||
if err != nil { | ||
t.Error("Email should have been parsed successfully") | ||
} | ||
expectedName := "example example" | ||
if e.Name != expectedName { | ||
t.Errorf("Expect email with name %s but got %s", expectedName, e.Name) | ||
} | ||
expectedAddress := "[email protected]" | ||
if e.Address != expectedAddress { | ||
t.Errorf("Expect email with address %s but got %s", expectedAddress, e.Address) | ||
} | ||
} | ||
|
||
func TestParseInvalidEmail(t *testing.T) { | ||
_, err := ParseEmail("example example <example/example.com>") | ||
if err == nil { | ||
t.Error("Expected an error to be thrown from ParseEmail") | ||
} | ||
} |