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

Test Mode #43

Closed
adamalbrecht opened this issue Mar 13, 2020 · 2 comments · Fixed by #117
Closed

Test Mode #43

adamalbrecht opened this issue Mar 13, 2020 · 2 comments · Fixed by #117
Labels

Comments

@adamalbrecht
Copy link

It would be nice if there were some sort of test mode where I can either just assert that a job was added to the queue or run the jobs immediately when queued.

Here is some information on how this is done in Sidekiq (for ruby):
https://github.com/mperham/sidekiq/wiki/Testing

Thanks!

@jwoertink
Copy link
Contributor

For anyone that happens to pop in here, I sort of monkey-patched for my case.

# spec/support/mosquito_helper.cr
module Mosquito
  abstract class QueuedJob < Job
    ENQUEUED_JOBS = [] of String
    def enqueue
      ENQUEUED_JOBS << self.class.name
    end
  end
end

# spec/your_thing_spec.cr

describe "Sending jobs" do
  before_each do
    Mosquito::QueuedJob::ENQUEUED_JOBS.clear
  end

  it "sends a job" do
     MyCode.run
     Mosquito::QueuedJob::ENQUEUED_JOBS.should contain("MyJob")
  end
end

but yes, an official way would be awesome.

@robacarp
Copy link
Collaborator

robacarp commented Oct 2, 2023

@adamalbrecht @jwoertink if you're still interested, please have a look at #117. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants