MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestComposeMultipartMessage

Function TestComposeMultipartMessage

internal/outbound/compose_test.go:292–322  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

290}
291
292func 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
324func TestComposeMultipartMessageFallsBackToPlain(t *testing.T) {
325 raw, err := ComposeMultipartMessage(

Callers

nothing calls this directly

Calls 3

ComposeMultipartMessageFunction · 0.85
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected