1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

policy: Tie mailbox extraction to Addressing for #33

This commit is contained in:
James Hillyerd
2018-04-02 20:15:50 -07:00
parent c2e1d58b90
commit 939ff19991
5 changed files with 57 additions and 70 deletions

View File

@@ -122,7 +122,9 @@ func TestShouldStoreDomain(t *testing.T) {
}
}
func TestParseMailboxName(t *testing.T) {
func TestExtractMailbox(t *testing.T) {
addrPolicy := policy.Addressing{Config: &config.Root{}}
var validTable = []struct {
input string
expect string
@@ -139,7 +141,7 @@ func TestParseMailboxName(t *testing.T) {
{"chars|}~", "chars|}~"},
}
for _, tt := range validTable {
if result, err := policy.ParseMailboxName(tt.input); err != nil {
if result, err := addrPolicy.ExtractMailbox(tt.input); err != nil {
t.Errorf("Error while parsing %q: %v", tt.input, err)
} else {
if result != tt.expect {
@@ -157,7 +159,7 @@ func TestParseMailboxName(t *testing.T) {
{"first\nlast", "Control chars not permitted"},
}
for _, tt := range invalidTable {
if _, err := policy.ParseMailboxName(tt.input); err == nil {
if _, err := addrPolicy.ExtractMailbox(tt.input); err == nil {
t.Errorf("Didn't get an error while parsing %q: %v", tt.input, tt.msg)
}
}