Skip to content

tests: add output/webhook tests for delivery and serialization #709

Description

@wolf31o2

Goal

Create the first test file for the webhook output plugin. There is currently no output/webhook/webhook_test.go.

Files

  • output/webhook/webhook.go, output/webhook/plugin.go, output/webhook/options.go (read)
  • output/webhook/webhook_test.go (new)

Changes

Add at least:

  • TestWebhookDeliverySuccess: stand up an httptest.NewServer that returns 200 and records the request body. Configure the plugin against the test URL, send a BlockEvent, and assert the request arrived with the expected JSON payload.
  • TestWebhookDeliveryFailure: test server returns 500. Send an event and assert the failure is logged or surfaced on the error channel rather than panicking.
  • TestWebhookEventSerialization: send a BlockEvent, a TransactionEvent, and a RollbackEvent through the plugin and assert each request body matches the documented JSON shape for that event type.

Use httptest.NewServer for the mock endpoint. Tear down with t.Cleanup.

Verification

go test -v -race ./output/webhook/...

Dependencies

None blocking. If the panic fix for the webhook plugin lands first, these tests can also cover the conversion-failure path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions