Skip to content

Commit

Permalink
Set REDIS_URL to use non-default host in test env
Browse files Browse the repository at this point in the history
  • Loading branch information
Tensho committed Dec 6, 2018
1 parent 840a919 commit ea48409
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions test/helper.rb
Expand Up @@ -20,6 +20,8 @@
end
end

ENV['REDIS_URL'] ||= 'redis://localhost/15'

Sidekiq.logger.level = Logger::ERROR

def capture_logging(lvl=Logger::INFO)
Expand Down
10 changes: 8 additions & 2 deletions test/test_redis_connection.rb
Expand Up @@ -7,6 +7,12 @@ class TestRedisConnection < Minitest::Test
describe ".create" do
before do
Sidekiq.options = Sidekiq::DEFAULTS.dup
@old = ENV['REDIS_URL']
ENV['REDIS_URL'] = 'redis://localhost/15'
end

after do
ENV['REDIS_URL'] = @old
end

# To support both redis-rb 3.3.x #client and 4.0.x #_client
Expand Down Expand Up @@ -82,7 +88,7 @@ def server_connection(*args)
it "disables client setname with nil id" do
pool = Sidekiq::RedisConnection.create(:id => nil)
assert_equal Redis, pool.checkout.class
assert_equal "redis://127.0.0.1:6379/0", pool.checkout.connection.fetch(:id)
assert_equal "redis://localhost:6379/15", pool.checkout.connection.fetch(:id)
end

describe "network_timeout" do
Expand Down Expand Up @@ -124,7 +130,7 @@ def server_connection(*args)
pool = Sidekiq::RedisConnection.create(:path => "/var/run/redis.sock")
assert_equal "unix", client_for(pool.checkout).scheme
assert_equal "/var/run/redis.sock", pool.checkout.connection.fetch(:location)
assert_equal 0, pool.checkout.connection.fetch(:db)
assert_equal 15, pool.checkout.connection.fetch(:db)
end

it "uses a given :path and :db" do
Expand Down

0 comments on commit ea48409

Please sign in to comment.