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

Function seedWebhookFixture

internal/webhookpub/worker_integration_test.go:18–51  ·  view source on GitHub ↗

seedWebhookFixture creates the full chain (user, domain, agent, webhook) needed to test slice-2 fan-out from a webhook_events row into webhook_subscriber_deliveries.

(t *testing.T, ctx context.Context, pool *pgxpool.Pool, store *identity.Store, slug string)

Source from the content-addressed store, hash-verified

16// webhook) needed to test slice-2 fan-out from a webhook_events row
17// into webhook_subscriber_deliveries.
18func seedWebhookFixture(t *testing.T, ctx context.Context, pool *pgxpool.Pool, store *identity.Store, slug string) (userID, agentEmail, webhookID string) {
19 t.Helper()
20 userID = "u_" + slug
21 domain := slug + ".example.com"
22 agentEmail = "agent@" + domain
23
24 _, err := pool.Exec(ctx,
25 `INSERT INTO users (id, email, name, google_subject, created_at)
26 VALUES ($1, $2, 'Worker Test', $1, now())
27 ON CONFLICT (id) DO NOTHING`,
28 userID, userID+"@example.com")
29 if err != nil {
30 t.Fatalf("seed user: %v", err)
31 }
32 if _, err := pool.Exec(ctx,
33 `INSERT INTO domains (domain, user_id, verified, verification_token, created_at)
34 VALUES ($1, $2, true, 'tkn', now())
35 ON CONFLICT (domain) DO NOTHING`,
36 domain, userID); err != nil {
37 t.Fatalf("seed domain: %v", err)
38 }
39 if _, err := store.CreateAgent(ctx, agentEmail, domain, "Worker Test Agent", "https://test.example.com/wh", "cloud", userID); err != nil {
40 t.Fatalf("seed agent: %v", err)
41 }
42
43 created, err := store.CreateWebhook(ctx, userID,
44 "https://test.example.com/webhook", "test",
45 []string{webhookpub.EventEmailReceived},
46 identity.WebhookFilters{})
47 if err != nil {
48 t.Fatalf("create webhook: %v", err)
49 }
50 return userID, agentEmail, created.ID
51}
52
53func TestOutboxWorker_Integration_FanOutDeliveries(t *testing.T) {
54 pool := testutil.TestDB(t)

Calls 3

CreateAgentMethod · 0.80
CreateWebhookMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected