-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_test.go
44 lines (41 loc) · 1.16 KB
/
mail_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"embed"
"testing"
)
//go:embed sample_emails/*
var f embed.FS
func TestParseMail_simple(t *testing.T) {
simpleEmail, err := f.Open("sample_emails/simple.eml")
expectedBody, err := f.ReadFile("sample_emails/simple.eml.txt")
if err != nil {
t.Fatal("reading simple.eml failed", err)
}
parsedMail, err := ParseMail(simpleEmail, dummyLogger)
if err != nil {
t.Error("unexpected error", err)
}
if parsedMail.PlainBody == "" {
t.Error("plain body is blank")
}
if parsedMail.PlainBody != string(expectedBody) {
t.Errorf("expected in sample_emails/simple.eml.txt, got %s", parsedMail.PlainBody)
}
}
func TestParseMail_comment(t *testing.T) {
simpleEmail, err := f.Open("sample_emails/comment.eml")
expectedBody, err := f.ReadFile("sample_emails/comment.eml.txt")
if err != nil {
t.Fatal("reading comment.eml failed", err)
}
parsedMail, err := ParseMail(simpleEmail, dummyLogger)
if err != nil {
t.Error("unexpected error", err)
}
if parsedMail.PlainBody == "" {
t.Error("plain body is blank")
}
if parsedMail.PlainBody != string(expectedBody) {
t.Errorf("expected in sample_emails/comment.eml.txt, got %s", parsedMail.PlainBody)
}
}