Skip to content

Conversation

@KengoWada
Copy link
Owner

Proposed changes

This pull request adds unit tests for the Worker struct. The tests cover key aspects of the worker's functionality, including task handling, retry logic, and graceful shutdown. The aim is to ensure the worker behaves correctly under different conditions and edge cases.

Changes include:

  • Added tests for task handling with valid and invalid tasks.
  • Implemented tests to verify retry logic using the backoff policy.
  • Created tests to ensure proper shutdown when the context is canceled or the task channel is closed.
  • Mocked broker used in the tests to simulate different broker behaviors, such as task consumption and error scenarios.

Related issue(s)

Fixes #4

Checklist

Please ensure that the following checks have been performed:

  • I have read and followed the project's contributing guidelines.
  • My code follows the project's coding style.
  • I have added or updated relevant documentation.
  • I have added or updated tests (if applicable).
  • All new and existing tests pass.
  • My changes do not introduce any new warnings or errors.

Implemented a mock Broker for testing purposes to simulate task consumption and handle errors for Worker tests.

Issue #4
Added unit tests for the Worker to cover task consumption, handler registration, retries, and backoff policy handling.

Issue #4
Replaced log.Fatalf with log.Printf to avoid premature termination.

Issue #4
@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@KengoWada KengoWada self-assigned this Apr 28, 2025
@KengoWada KengoWada merged commit c76e555 into develop Apr 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] - Add tests for Worker

3 participants