From 925b80e85e9392daf2a4ad3aa8ffd7af101a7e85 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Sun, 8 Jun 2014 13:43:22 +1000 Subject: [PATCH 1/4] restore env vars to original values after these tests --- test/test_redis_connection.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_redis_connection.rb b/test/test_redis_connection.rb index fdbcc1eb..f236a328 100644 --- a/test/test_redis_connection.rb +++ b/test/test_redis_connection.rb @@ -70,6 +70,14 @@ class TestRedisConnection < Sidekiq::Test describe ".determine_redis_provider" do + before do + @old_env = ENV.to_h + end + + after do + ENV.update(@old_env) + end + def with_env_var(var, uri, skip_provider=false) vars = ['REDISTOGO_URL', 'REDIS_PROVIDER', 'REDIS_URL'] - [var] vars.each do |v| From 2efd7b6ddcb0870a0af8c050d4fb3c60ec2b4bcc Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Sun, 8 Jun 2014 13:44:35 +1000 Subject: [PATCH 2/4] store REDIS_URL in a constant --- test/helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 7d081260..03ff0e0f 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -31,9 +31,9 @@ Sidekiq.logger.level = Logger::ERROR Sidekiq::Test = Minitest::Test require 'sidekiq/redis_connection' -redis_url = ENV['REDIS_URL'] || 'redis://localhost/15' -REDIS = Sidekiq::RedisConnection.create(:url => redis_url, :namespace => 'testy') +REDIS_URL = ENV['REDIS_URL'] || 'redis://localhost/15' +REDIS = Sidekiq::RedisConnection.create(:url => REDIS_URL, :namespace => 'testy') Sidekiq.configure_client do |config| - config.redis = { :url => redis_url, :namespace => 'testy' } + config.redis = { :url => REDIS_URL, :namespace => 'testy' } end From 0fa82c28fcd3d282e4e4c333ca429212d12027b4 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Sun, 8 Jun 2014 13:45:20 +1000 Subject: [PATCH 3/4] use the right redis url when reconnecting in TestFetcher --- test/test_fetch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_fetch.rb b/test/test_fetch.rb index 08aa741a..121cff98 100644 --- a/test/test_fetch.rb +++ b/test/test_fetch.rb @@ -4,7 +4,7 @@ require 'sidekiq/fetch' class TestFetcher < Sidekiq::Test describe 'fetcher' do before do - Sidekiq.redis = { :namespace => 'fuzzy' } + Sidekiq.redis = { :url => REDIS_URL, :namespace => 'fuzzy' } Sidekiq.redis do |conn| conn.flushdb conn.rpush('queue:basic', 'msg') From f920fbc0ed2d20e13dadee469af6d1ec396bfd17 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Sun, 8 Jun 2014 13:53:47 +1000 Subject: [PATCH 4/4] use ENV.to_hash instead of ENV.to_h to support antique rubies --- test/test_redis_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_redis_connection.rb b/test/test_redis_connection.rb index f236a328..4a4eb85f 100644 --- a/test/test_redis_connection.rb +++ b/test/test_redis_connection.rb @@ -71,7 +71,7 @@ class TestRedisConnection < Sidekiq::Test describe ".determine_redis_provider" do before do - @old_env = ENV.to_h + @old_env = ENV.to_hash end after do