sendhooks-engine icon indicating copy to clipboard operation
sendhooks-engine copied to clipboard

Write Unit Tests for the `queue` Package

Open koladev32 opened this issue 1 year ago • 0 comments

The queue package plays a vital role in our application, handling the queuing, retries, and exponential backoff logic for webhook deliveries. Comprehensive tests will ensure the reliability and robustness of this component.

Scope:

  1. Test ProcessWebhooks:

    • Ensure that sendWebhookWithRetries is invoked for each payload in the webhookQueue.
    • Test with varying numbers of payloads.
  2. Test sendWebhookWithRetries:

    • Confirm that retryWithExponentialBackoff is correctly invoked.
    • Ensure logging takes place if a webhook fails after maximum retries.
  3. Test calculateBackoff:

    • Validate the calculation of backoff times.
    • Confirm the doubling of backoff until it reaches maxBackoff.
  4. Test retryWithExponentialBackoff:

    • Mock the behavior of sender.SendWebhook to simulate both successful sends and failures.
    • Confirm retries happen the expected number of times (maxRetries).
    • Ensure backoff time increases exponentially with each retry.
    • Validate logging behavior at each retry and when maximum retries are reached.

koladev32 avatar Sep 09 '23 04:09 koladev32