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

Function TestGetOutboundMessageForUser

internal/identity/hitl_approve_test.go:41–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestGetOutboundMessageForUser(t *testing.T) {
42 pool := testutil.TestDB(t)
43 store := identity.NewStore(pool)
44 ctx := context.Background()
45
46 user, a := setupPendingAgent(t, store, "get-ob")
47
48 atts, _ := json.Marshal([]map[string]string{{"filename": "f.txt", "content_type": "text/plain", "data": "aA=="}})
49 msg, err := store.CreatePendingOutboundMessage(
50 ctx, a.ID,
51 []string{"alice@example.com"}, nil, nil,
52 "Draft", "plain", "<p>html</p>",
53 atts,
54 "send", "conv_1", "",
55 3600,
56 )
57 if err != nil {
58 t.Fatalf("CreatePendingOutboundMessage: %v", err)
59 }
60
61 got, err := store.GetOutboundMessageForUser(ctx, msg.ID, user.ID)
62 if err != nil {
63 t.Fatalf("GetOutboundMessageForUser: %v", err)
64 }
65 if got.Status != identity.MessageStatusPendingReview {
66 t.Errorf("Status = %q", got.Status)
67 }
68 if got.Subject != "Draft" {
69 t.Errorf("Subject = %q", got.Subject)
70 }
71 if got.BodyText != "plain" {
72 t.Errorf("BodyText = %q", got.BodyText)
73 }
74 if got.BodyHTML != "<p>html</p>" {
75 t.Errorf("BodyHTML = %q", got.BodyHTML)
76 }
77 if len(got.AttachmentsJSON) == 0 {
78 t.Error("AttachmentsJSON empty")
79 }
80 if got.ApprovalExpiresAt == nil {
81 t.Error("ApprovalExpiresAt nil")
82 }
83 if got.Type != "send" {
84 t.Errorf("Type = %q", got.Type)
85 }
86}
87
88func TestGetOutboundMessageForUserCrossUserIsNotFound(t *testing.T) {
89 pool := testutil.TestDB(t)

Callers

nothing calls this directly

Calls 6

TestDBFunction · 0.92
NewStoreFunction · 0.92
setupPendingAgentFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected