mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #446] [FEATURE REQUEST] Expose asynq context to facilitate client testing #203
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#203
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @strobus on GitHub (May 1, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/446
Originally assigned to: @hibiken on GitHub.
Is your feature request related to a problem? Please describe.
I'm writing a system where I need careful tracking of tasks and their corresponding business objects, with the ability to query them. So I'm putting the task ID and other data in a database. My code naturally uses the
asynq.GetTaskID(ctx)function to get the task ID. The issue I'm having is trying to write tests for this code. I have no way of creating a context thatasynq.GetTaskID(ctx)will accept without some ugly hacks.Describe the solution you'd like
I need the
contextpackage in theinternaldirectory to be exposed externally. Alternatively we need to create a separate package with some simple functions to create a mock context.Describe alternatives you've considered
Hacking using module introspection and reflection, which is very time consuming for what should be a simple exercise.
Additional context
I would be happy to work on a fix to this issue.
@hibiken commented on GitHub (May 2, 2022):
@strobus Thanks for opening this issue!
I think it makes sense to create a test utility package under
/x/asynqtest.PR is welcome!
@kayandra commented on GitHub (Nov 22, 2023):
hello @hibiken I'm also interested in having an asynqtest module exposed so it making testing easier. I couldn't figure out how @strobus made hacks for testing processors, I believe we should have a mocked client/worker that we can use to test tasks.