(t *testing.T)
| 290 | } |
| 291 | |
| 292 | func TestComposeMultipartMessage(t *testing.T) { |
| 293 | raw, err := ComposeMultipartMessage( |
| 294 | "bot@agent.example.com", []string{"alice@gmail.com"}, nil, |
| 295 | "Re: Hello", "Plain text body", "<p>HTML body</p>", |
| 296 | "<orig@example.com>", nil, "relay.e2a.dev", "", "", |
| 297 | ) |
| 298 | if err != nil { |
| 299 | t.Fatalf("ComposeMultipartMessage failed: %v", err) |
| 300 | } |
| 301 | |
| 302 | msg, err := mail.ReadMessage(strings.NewReader(string(raw))) |
| 303 | if err != nil { |
| 304 | t.Fatalf("failed to parse multipart message: %v", err) |
| 305 | } |
| 306 | |
| 307 | ct := msg.Header.Get("Content-Type") |
| 308 | if !strings.Contains(ct, "multipart/alternative") { |
| 309 | t.Errorf("Content-Type = %q, want multipart/alternative", ct) |
| 310 | } |
| 311 | if got := msg.Header.Get("In-Reply-To"); got != "<orig@example.com>" { |
| 312 | t.Errorf("In-Reply-To = %q, want <orig@example.com>", got) |
| 313 | } |
| 314 | |
| 315 | body := string(raw) |
| 316 | if !strings.Contains(body, "Plain text body") { |
| 317 | t.Error("expected plain text part in message body") |
| 318 | } |
| 319 | if !strings.Contains(body, "<p>HTML body</p>") { |
| 320 | t.Error("expected HTML part in message body") |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | func TestComposeMultipartMessageFallsBackToPlain(t *testing.T) { |
| 325 | raw, err := ComposeMultipartMessage( |
nothing calls this directly
no test coverage detected