triggerBoth fires the event through BOTH paths, mirroring the rollout-window state where the legacy goroutine + new outbox both run. Returns the deterministic event id.
(ctx context.Context, userID, agentID, messageID string)
| 51 | // rollout-window state where the legacy goroutine + new outbox both |
| 52 | // run. Returns the deterministic event id. |
| 53 | func (f *dualPathFixture) triggerBoth(ctx context.Context, userID, agentID, messageID string) string { |
| 54 | f.t.Helper() |
| 55 | f.seedMessage(messageID, agentID, "inbound") |
| 56 | eventID := webhookpub.DeterministicEventID(messageID, webhookpub.EventEmailReceived) |
| 57 | event := webhookpub.Event{ |
| 58 | ID: eventID, |
| 59 | Type: webhookpub.EventEmailReceived, |
| 60 | UserID: userID, |
| 61 | AgentID: agentID, |
| 62 | MessageID: messageID, |
| 63 | Data: map[string]any{"path": "dual"}, |
| 64 | } |
| 65 | // Path 1: outbox (no-op if the flag is off). |
| 66 | if err := f.store.WithTx(ctx, func(tx pgx.Tx) error { |
| 67 | return f.outbox.PublishTx(ctx, tx, event) |
| 68 | }); err != nil { |
| 69 | f.t.Fatalf("PublishTx: %v", err) |
| 70 | } |
| 71 | // Path 2: legacy in-process fan-out (always fires). |
| 72 | f.legacyPublisher.Publish(ctx, event) |
| 73 | // Drain everything so the test can immediately assert. |
| 74 | f.worker.Tick(ctx) |
| 75 | f.subWorker.Tick(ctx) |
| 76 | return eventID |
| 77 | } |
| 78 | |
| 79 | // TestDualPath_FlagOff_OnlyLegacyDelivers proves that with the |
| 80 | // WEBHOOKS_OUTBOX_ENABLED flag OFF (the v1 default), the legacy |
no test coverage detected