You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To ensure our sender package is reliable and robust, we need to implement a comprehensive suite of unit tests. Specifically, the focus will be on the SendWebhook function, as well as any auxiliary functions it calls.
Scope:
Test marshalJSON:
Ensure correct JSON marshaling with valid data structures.
Test with invalid structures and ensure that errors are correctly returned.
Test prepareRequest:
Ensure the request is correctly prepared with the given URL, JSON bytes, and secret hash.
Confirm headers (like Content-Type and X-Secret-Hash) are appropriately set.
Test sendRequest:
Mock different scenarios including:
Successful responses.
Client Errors (e.g., HTTP 400).
Server Errors (e.g., HTTP 500).
Ensure errors are returned as expected.
Test closeResponse:
Verify that the response body is correctly closed.
Ensure that any errors during the closure are handled appropriately.
Test processResponse:
Check that the function correctly determines the status based on various mocked response codes and bodies.
Ensure the function returns the response body and any potential errors.
Test Overall Flow in SendWebhook:
Successful webhook sending.
Failed webhook due to request preparation errors.
Failed webhook due to marshaling errors.
Failed webhook due to response processing errors.
Logging on failed webhook delivery (checking the invocation of WebhookLogger).
The text was updated successfully, but these errors were encountered:
To ensure our
sender
package is reliable and robust, we need to implement a comprehensive suite of unit tests. Specifically, the focus will be on theSendWebhook
function, as well as any auxiliary functions it calls.Scope:
Test
marshalJSON
:Test
prepareRequest
:Content-Type
andX-Secret-Hash
) are appropriately set.Test
sendRequest
:Test
closeResponse
:Test
processResponse
:Test Overall Flow in
SendWebhook
:WebhookLogger
).The text was updated successfully, but these errors were encountered: