fakeredis
fakeredis copied to clipboard
Should it work with current sidekiq?
Reaching way back here, but back in #66 (almost 10 years ago!) some discussion was happening about how to get fakeredis to work with sidekiq, but I haven't had any luck. It might be related to redis changes moreso than sidekiq, but I'll lay out what I have tried...
Just setting the driver as stated like redis_details.merge!(:driver => Redis::Connection::Memory) if defined?(Redis::Connection::Memory)
doesn't work as sidekiq's adapter is expecting a symbol:
Minitest::UnexpectedError: NoMethodError: undefined method `to_sym' for Redis::Connection::Memory:Class
opts[:driver] = opts[:driver].to_sym
^^^^^^^
Did you mean? to_s
sidekiq (7.1.0) lib/sidekiq/redis_client_adapter.rb:79:in `client_opts'
Ok, so I attempt to register the driver myself:
RedisClient.register_driver :memory do
Redis::Connection::Memory
end
redis_details.merge!(:driver => :memory) if defined?(Redis::Connection::Memory)
But the redis-client can't initialize the Memory object because the arguments don't line up:
Minitest::UnexpectedError: ArgumentError: wrong number of arguments (given 2, expected 0..1)
fakeredis (0.9.2) lib/redis/connection/memory.rb:57:in `initialize'
redis-client (0.14.1) lib/redis_client.rb:671:in `new'
Is there some other way to make this happen, or is the Memory driver no longer compatible?
@maurercw Unfortunately, fakeredis isn't compatible with redis-client and Sidekiq 7 depends on redis-client.
There are more details about redis-client/sidekiq at https://github.com/sds/mock_redis/issues/253 (the issue with fakeredis is exactly the same)
FWIW, depending on what you need in the test env for sidekiq, you can enable inline mode
require 'sidekiq/testing'
Sidekiq::Testing.inline!