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

Function TestCreateAndGetInboundMessage

internal/identity/store_test.go:345–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

343}
344
345func TestCreateAndGetInboundMessage(t *testing.T) {
346 pool := testutil.TestDB(t)
347 store := identity.NewStore(pool)
348 ctx := context.Background()
349
350 user, _ := store.CreateOrGetUser(ctx, "owner@example.com", "Owner", "google-inbound")
351 store.ClaimOrCreateDomain(ctx, "inbound.example.com", user.ID)
352 a, _ := store.CreateAgent(ctx, "agent@inbound.example.com", "inbound.example.com", "", "https://example.com/webhook", "", user.ID)
353
354 msg, err := store.CreateInboundMessage(ctx, "", a.ID, "alice@gmail.com", "bot@inbound.example.com", "<abc123@gmail.com>", "Hello Bot", "", "", nil, nil, nil, false, "", nil, nil, nil, identity.InboundScreening{})
355 if err != nil {
356 t.Fatalf("CreateInboundMessage: %v", err)
357 }
358 if !strings.HasPrefix(msg.ID, "msg_") {
359 t.Errorf("ID should start with msg_, got %q", msg.ID)
360 }
361 if msg.AgentID != a.ID {
362 t.Errorf("AgentID = %q, want %q", msg.AgentID, a.ID)
363 }
364 if msg.Direction != "inbound" {
365 t.Errorf("Direction = %q, want inbound", msg.Direction)
366 }
367 if msg.Sender != "alice@gmail.com" {
368 t.Errorf("Sender = %q", msg.Sender)
369 }
370 if msg.EmailMessageID != "<abc123@gmail.com>" {
371 t.Errorf("EmailMessageID = %q", msg.EmailMessageID)
372 }
373 if msg.Subject != "Hello Bot" {
374 t.Errorf("Subject = %q", msg.Subject)
375 }
376
377 got, err := store.GetInboundMessage(ctx, msg.ID)
378 if err != nil {
379 t.Fatalf("GetInboundMessage: %v", err)
380 }
381 if got.ID != msg.ID {
382 t.Errorf("ID mismatch")
383 }
384}
385
386// TestInboundMessageRoundTripsAuthVerdict asserts the structured inbound
387// auth verdict (messages.auth_verdict, migration 032) persists and reads

Callers

nothing calls this directly

Calls 7

CreateOrGetUserMethod · 0.95
ClaimOrCreateDomainMethod · 0.95
CreateAgentMethod · 0.95
CreateInboundMessageMethod · 0.95
GetInboundMessageMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92

Tested by

no test coverage detected