Comments (5)
@dsusviela directly creating callbacks from an AR callback might not be the cleanest way to do it. However since sidekiq-cron is well tested, I would stub this dependency and just accept the fact, that when Sidekiq::Cron::Job.create
is being called, that everything that comes after that works as expected.
If you want to have a working integration spec you can think about setting https://github.com/sds/mock_redis
as your redis backend for sidekiq. That should work as well, right?
from sidekiq-cron.
Hi @dsusviela thanks for your words! really appreciated!
What do you exactly mean by "a problem"? Do you want to somehow mockup the redis
object? This will require to implement some kind of "adapter" thing, as this code Sidekiq.redis
is used in several places. Do you know if Sidekiq itself does something similar?
from sidekiq-cron.
Hey @markets!
Maybe I can give a more practical example:
Suppose I have a Rails App, that has a model named Task
. I will write some code from memory so excuse me if its not really runnable. If you want I can give an actual runnable script.
class Task < ActiveRecord
after_save :create_task
def create_task
Sidekiq::Cron::Job.create("some args here")
end
end
Suppose now that I want to run the following test suite (in my case rspec):
describe Task do
context "when creating a valid task" do
it "creates a sidekiq cron job"
# i know this matcher doesn't exist but bear with me
expect(Task.create("take dog to the vet")).to_have_created_sidekiq_cron
end
end
end
Now if i go to localhost:3000/sidekiq/cron
I can see the task "take dog to the vet".
In my opinion I should be able to configure the backend for sidekiq cron in an initializer file or I should be able to include a file like we do in normal sidekiq ie, sidekiq/rspec
that solves this problem.
However maybe my whole approach is wrong, and the smell that I have comes from a different angle (like creating cron jobs from an AR callback).
from sidekiq-cron.
Would be nice if we can re-use any of those sidekiq
provided helpers/classes to provide similar strategy for testing sidekiq-cron
. Maybe we can't re-use it, but we can use it as inspiration to provide similar stuff. Happy to review any PR in this direction.
from sidekiq-cron.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from sidekiq-cron.
Related Issues (20)
- Add ability to differentiate between regular cron jobs and dynamic cron jobs
- Clear non-dynamic cron jobs upon loading the schedule
- Undefined method perform_later HOT 5
- Not respecting SSL_PARAMS for redis on heroku HOT 3
- Sidekiq Cron is not compaireable with Sidekiq 7.0.8 => `require': cannot load such file -- sidekiq/util (LoadError) HOT 1
- [ActiveJob] Cannot use `queue_as` for select queue, only sidekiq options are supported (first run) HOT 3
- Avoid using Sidekiq.redis in Sidekiq 7 to avoid pool contention HOT 1
- Args are not parsed when using the public "args=" method HOT 2
- Args are not symbolized when passing "symbolize_args: true" HOT 6
- Add a strict evaluation mode for cron expressions HOT 13
- Cron tab in Web UI miscolored in Sidekiq Pro v7 HOT 2
- Task names with forward slashes cannot be enqueued manually in the web UI HOT 1
- Violation of Sidekiq Best Practices HOT 7
- [Question] Monitor Sidekiq Cron Workers HOT 1
- Ability to configure the past schedule interval HOT 2
- Missing some schedule instance on sidekiq-cron HOT 2
- load_from_array! showing "Cron Jobs - added job with name ..." for previously added jobs HOT 1
- Sidekiq 7.3 compatibility HOT 6
- Rails - trying to configer namespace via initializer fails with undefined method `configure' HOT 1
- Queue name not used as configured by sidekiq_options queue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sidekiq-cron.