Framework.Test.MockWebhookService (Framework v0.5.0)
View SourceMock webhook service for testing retry scenarios and uniqueness verification.
This GenServer tracks webhook calls by idempotency key to prove that duplicate requests/retries result in single external calls.
Features
- Track calls by Idempotency-Key header
- Simulate different HTTP status codes (2xx, 4xx, 5xx)
- Count attempts vs successful outcomes per idempotency key
- Reset state for clean test runs
- Query call history for verification
Architecture
This service only tracks webhook calls. Bypass HTTP server setup is handled in test setup to maintain ExUnit/Bypass compatibility.
Summary
Functions
Returns a specification to start this module under a supervisor.
Configure a webhook endpoint to return specific status codes.
Get all idempotency keys that have been called.
Get call history for a specific idempotency key. Returns: %{attempts: count, successful_outcomes: count, last_status: integer}
Helper function for Bypass test setup. Extracts header value from connection.
Helper function for Bypass test setup. Extracts webhook name from request path.
Reset all call tracking - useful for clean test runs.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Configure a webhook endpoint to return specific status codes.
Examples: configure_response("user.created", status: 200) configure_response("billing.charge", status: 500, attempts: 3) configure_response("notifications.send", status: 422)
Get all idempotency keys that have been called.
Get call history for a specific idempotency key. Returns: %{attempts: count, successful_outcomes: count, last_status: integer}
Helper function for Bypass test setup. Extracts header value from connection.
Helper function for Bypass test setup. Extracts webhook name from request path.
Reset all call tracking - useful for clean test runs.