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.
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 anhttptest.NewServerthat returns 200 and records the request body. Configure the plugin against the test URL, send aBlockEvent, 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 aBlockEvent, aTransactionEvent, and aRollbackEventthrough the plugin and assert each request body matches the documented JSON shape for that event type.Use
httptest.NewServerfor the mock endpoint. Tear down witht.Cleanup.Verification
Dependencies
None blocking. If the panic fix for the webhook plugin lands first, these tests can also cover the conversion-failure path.