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

Function TestProvisionToVerified

internal/senderidentity/integration_test.go:99–133  ·  view source on GitHub ↗

TestProvisionToVerified drives the full River-backed flow against a real DB with a FakeProvider: EnqueueProvision → ProvisionWorker (pending) → enqueued ReconcileWorker → FakeProvider reports verified → domain.sending_status becomes "verified" and domain.sending_verified fires.

(t *testing.T)

Source from the content-addressed store, hash-verified

97// ReconcileWorker → FakeProvider reports verified → domain.sending_status
98// becomes "verified" and domain.sending_verified fires.
99func TestProvisionToVerified(t *testing.T) {
100 pool := testutil.TestDB(t)
101 ctx := context.Background()
102 store := identity.NewStore(pool)
103
104 freshRiver(t, pool)
105 _, domain := setupVerifiedDomain(t, store, "siprov")
106
107 fake := senderidentity.NewFakeProvider()
108 // First reconcile poll already reports verified → no backoff wait.
109 fake.SetStatus(domain, senderidentity.Result{Status: senderidentity.StatusVerified})
110
111 rec := &recordingFire{}
112 mgr, err := senderidentity.NewManager(pool, senderidentity.NewStoreAdapter(store), fake, rec.firer(), senderidentity.Config{})
113 if err != nil {
114 t.Fatalf("NewManager: %v", err)
115 }
116 if err := mgr.Start(ctx); err != nil {
117 t.Fatalf("Start: %v", err)
118 }
119 defer mgr.Stop(context.Background())
120
121 if err := mgr.EnqueueProvision(ctx, domain); err != nil {
122 t.Fatalf("EnqueueProvision: %v", err)
123 }
124
125 waitForStatus(t, store, domain, "verified", 15*time.Second)
126
127 if len(fake.ProvisionCalls) == 0 {
128 t.Error("expected Provision to be called")
129 }
130 if rec.count() == 0 {
131 t.Error("expected domain.sending_verified to fire")
132 }
133}
134
135// TestProvisionFailsClosed drives a provider that reports the verification
136// failed: status must end at "failed" (relay From, fail-closed) with the

Callers

nothing calls this directly

Calls 15

SetStatusMethod · 0.95
firerMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
EnqueueProvisionMethod · 0.95
countMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92
NewFakeProviderFunction · 0.92
NewManagerFunction · 0.92
NewStoreAdapterFunction · 0.92
freshRiverFunction · 0.85

Tested by

no test coverage detected