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

Function TestSelfSend_DetectionEdgeCases

internal/agent/selfsend_test.go:21–47  ·  view source on GitHub ↗

TestSelfSend_DetectionEdgeCases: case-insensitive, whitespace- trimmed, single-address requirement. Mixed/external recipients must fall through to SMTP (covered indirectly — TestSendEmailViaSMTP already exercises the non-loopback path).

(t *testing.T)

Source from the content-addressed store, hash-verified

19// fall through to SMTP (covered indirectly — TestSendEmailViaSMTP
20// already exercises the non-loopback path).
21func TestSelfSend_DetectionEdgeCases(t *testing.T) {
22 cases := []struct {
23 name string
24 to []string
25 cc []string
26 want bool
27 reason string
28 }{
29 {"exact match", []string{"bot@x.com"}, nil, true, ""},
30 {"case-insensitive local", []string{"BOT@x.com"}, nil, true, "ASCII case-insensitive"},
31 {"case-insensitive domain", []string{"bot@X.COM"}, nil, true, "domain comparison is case-insensitive"},
32 {"whitespace trimmed", []string{" bot@x.com "}, nil, true, "trim should normalize"},
33 {"different address", []string{"other@x.com"}, nil, false, "not self"},
34 {"self plus external in To", []string{"bot@x.com", "other@x.com"}, nil, false, "external recipient → SMTP"},
35 {"self plus cc", []string{"bot@x.com"}, []string{"cc@x.com"}, false, "cc → SMTP"},
36 {"empty to", []string{}, nil, false, ""},
37 }
38 for _, c := range cases {
39 t.Run(c.name, func(t *testing.T) {
40 req := outbound.SendRequest{To: c.to, CC: c.cc}
41 got := agent.IsSelfSendForTest(req, "bot@x.com")
42 if got != c.want {
43 t.Errorf("isSelfSend(%v, cc=%v) = %v, want %v (%s)", c.to, c.cc, got, c.want, c.reason)
44 }
45 })
46 }
47}
48
49// setupCoreAPI builds an *agent.API wired to a real test DB so tests can drive
50// the extracted outbound core (DeliverOutbound) directly. The legacy

Callers

nothing calls this directly

Calls 2

IsSelfSendForTestFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected