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

Function TestComposeMessageSubjectRFC2047Encoding

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

Source from the content-addressed store, hash-verified

48}
49
50func TestComposeMessageSubjectRFC2047Encoding(t *testing.T) {
51 raw, err := ComposeMessage(
52 "from@test.com", []string{"to@test.com"}, nil,
53 "Résumé 📄 for アリス", "Body", "text/plain", "", nil, "test.dev", "", "",
54 )
55 if err != nil {
56 t.Fatalf("ComposeMessage failed: %v", err)
57 }
58
59 // Raw header must be 7-bit ASCII (RFC 5322 §2.2).
60 headerEnd := strings.Index(string(raw), "\r\n\r\n")
61 if headerEnd < 0 {
62 t.Fatal("no header/body separator")
63 }
64 for i, b := range []byte(string(raw)[:headerEnd]) {
65 if b > 127 {
66 t.Fatalf("non-ASCII byte 0x%x at offset %d in headers", b, i)
67 }
68 }
69
70 // Go's mail.ReadMessage + WordDecoder should round-trip the subject.
71 msg, err := mail.ReadMessage(strings.NewReader(string(raw)))
72 if err != nil {
73 t.Fatalf("parse: %v", err)
74 }
75 dec := new(mime.WordDecoder)
76 got, err := dec.DecodeHeader(msg.Header.Get("Subject"))
77 if err != nil {
78 t.Fatalf("decode subject: %v", err)
79 }
80 if got != "Résumé 📄 for アリス" {
81 t.Errorf("decoded subject = %q, want %q", got, "Résumé 📄 for アリス")
82 }
83}
84
85// TestComposeMessageSubjectCRLFNeutralized confirms that even if a CRLF
86// reaches ComposeMessage (e.g. some future caller skips the API-layer

Callers

nothing calls this directly

Calls 2

ComposeMessageFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected