Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidekiq Enterprise: until matcher #232

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wizardofelves
Copy link

@wizardofelves wizardofelves commented Jan 31, 2025

Description

In Sidekiq Enterprise's Unique Jobs feature, you have the ability to specify an unlock policy.

This PR adds an until matcher so that you may specify an expectation against a worker for it like so:

describe MuhWorker do
  it { should be_unique.until(:success) }
end

It also will fail that it is not supported if a user tries to use it with SidekiqUniqueJobs.

(all credit to @leviwilson for his work on this, I just rebased and brought it current)

Sidekiq Enterprise use a unique_until option to
specify when the uniqueness is allowed to go
away.

This matcher allows you to write specifications
against a worker to validate those expectations.
@wspurgin
Copy link
Owner

wspurgin commented Feb 3, 2025

Thanks @wizardofelves and @leviwilson for the original effort here. SidekiqUniqueJobs does support it's own testing https://github.com/mhenrixon/sidekiq-unique-jobs?tab=readme-ov-file#validating-worker-configuration and we likely could support until by interrogating the lock option it sets.

However, this doesn't need to wait for that - having it for Ent users of Sidekiq will be welcome on its own.

MuhWorker
end

it { should be_unique.for(interval).until(:success) }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 Can you add something akin to this and the other subject below as examples to the README? As well as specifying that SidekiqUniqueJobs is not yet supported for this matcher?

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.

3 participants