(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestParseEmail_PlainText(t *testing.T) { |
| 10 | raw := []byte("From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: Test Subject\r\nContent-Type: text/plain\r\nMessage-ID: <test123@example.com>\r\n\r\nHello, this is a test email.") |
| 11 | |
| 12 | parsed, atts, err := parseEmail(raw, []string{"recipient@example.com"}) |
| 13 | if err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | |
| 17 | if parsed.Subject != "Test Subject" { |
| 18 | t.Errorf("Subject = %q, want %q", parsed.Subject, "Test Subject") |
| 19 | } |
| 20 | if len(parsed.From) != 1 || parsed.From[0].Email != "sender@example.com" { |
| 21 | t.Errorf("From = %+v", parsed.From) |
| 22 | } |
| 23 | if len(parsed.To) != 1 || parsed.To[0].Email != "recipient@example.com" { |
| 24 | t.Errorf("To = %+v", parsed.To) |
| 25 | } |
| 26 | if parsed.Text != "Hello, this is a test email." { |
| 27 | t.Errorf("Text = %q", parsed.Text) |
| 28 | } |
| 29 | if parsed.HTML != "" { |
| 30 | t.Errorf("HTML should be empty, got %q", parsed.HTML) |
| 31 | } |
| 32 | if parsed.ID == nil || *parsed.ID != "<test123@example.com>" { |
| 33 | t.Errorf("ID = %v", parsed.ID) |
| 34 | } |
| 35 | if len(atts) != 0 { |
| 36 | t.Errorf("expected no attachments, got %d", len(atts)) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestParseEmail_HTML(t *testing.T) { |
| 41 | raw := []byte("From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: HTML Test\r\nContent-Type: text/html\r\n\r\n<p>Hello HTML</p>") |
nothing calls this directly
no test coverage detected