Skip to content

Commit

Permalink
test brought in line with the others
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusan Kasan authored and Dusan Kasan committed Apr 6, 2020
1 parent 9b69db4 commit 1ce83dc
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions parsemail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,31 @@ So, "Hello".`,
},
},
},
12: {
contentType: "multipart/related; boundary=\"000000000000ab2e2205a26de587\"",
mailData: multipartRelatedExample,
subject: "Saying Hello",
from: []mail.Address{
{
Name: "John Doe",
Address: "jdoe@machine.example",
},
},
sender: mail.Address{
Name: "Michael Jones",
Address: "mjones@machine.example",
},
to: []mail.Address{
{
Name: "Mary Smith",
Address: "mary@example.net",
},
},
messageID: "1234@local.machine.example",
date: parseDate("Fri, 21 Nov 1997 09:55:06 -0600"),
htmlBody: "<div dir=\"ltr\"><div>Time for the egg.</div><div><br></div><div><br><br></div></div>",
textBody: "Time for the egg.",
},
}

for index, td := range testData {
Expand Down Expand Up @@ -540,27 +565,6 @@ So, "Hello".`,
}
}

func TestMultiPartRelatedEmail(t *testing.T) {
email, err := Parse(strings.NewReader(multipartRelatedExample))
if err != nil {
t.Errorf("[Test Multipart Related] Emailed failed to parse: %v", err)
}

if len(email.TextBody) == 0 {
t.Errorf("[Test Multipart Related] Failed to parse multipart related at the top level.")
}
body := "Time for the egg."
fmt.Println(email.TextBody)
if email.TextBody != body {
t.Errorf("Test Multipart Related] Body didn't match. \nExpected: %v,\nbut got: %v", body, email.TextBody)
}

html := "<div dir=\"ltr\"><div>Time for the egg.</div><div><br></div><div><br><br></div></div>"
if email.HTMLBody != html {
t.Errorf("Test Multipart Related] HTML didn't match. \nExpected: %v,\nbut got: %v", html, email.TextBody)
}
}

func parseDate(in string) time.Time {
out, err := time.Parse(time.RFC1123Z, in)
if err != nil {
Expand Down

0 comments on commit 1ce83dc

Please sign in to comment.