mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Fix issues with non-deterministic global test state
This commit is contained in:
parent
1f870fabbb
commit
c49e1f9ab7
7 changed files with 22 additions and 11 deletions
|
@ -20,7 +20,7 @@ module Sidekiq
|
||||||
|
|
||||||
class CLI
|
class CLI
|
||||||
include Util
|
include Util
|
||||||
include Singleton
|
include Singleton unless $TESTING
|
||||||
|
|
||||||
# Used for CLI testing
|
# Used for CLI testing
|
||||||
attr_accessor :code
|
attr_accessor :code
|
||||||
|
|
|
@ -261,7 +261,7 @@ class TestApi < Sidekiq::Test
|
||||||
|
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
refute conn.smembers('queues').include?('foo')
|
refute conn.smembers('queues').include?('foo')
|
||||||
refute conn.exists('queues:foo')
|
refute conn.exists('queue:foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,26 @@ require 'helper'
|
||||||
require 'sidekiq/cli'
|
require 'sidekiq/cli'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
||||||
cli = Sidekiq::CLI.instance
|
class Sidekiq::CLI
|
||||||
def cli.die(code)
|
def die(code)
|
||||||
@code = code
|
@code = code
|
||||||
end
|
end
|
||||||
|
|
||||||
def cli.valid?
|
def valid?
|
||||||
!@code
|
!@code
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestCli < Sidekiq::Test
|
class TestCli < Sidekiq::Test
|
||||||
describe 'CLI#parse' do
|
describe 'CLI#parse' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@cli = Sidekiq::CLI.instance
|
@cli = Sidekiq::CLI.new
|
||||||
|
@opts = Sidekiq.options.dup
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Sidekiq.options = @opts
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not require the specified Ruby code' do
|
it 'does not require the specified Ruby code' do
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TestClient < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Sidekiq.instance_variable_set(:@redis, REDIS)
|
Sidekiq.redis = REDIS
|
||||||
Sidekiq::Client.instance_variable_set(:@default, nil)
|
Sidekiq::Client.instance_variable_set(:@default, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@ class TestFetcher < Sidekiq::Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Sidekiq.redis = REDIS
|
||||||
|
end
|
||||||
|
|
||||||
it 'retrieves' do
|
it 'retrieves' do
|
||||||
fetch = Sidekiq::BasicFetch.new(:queues => ['basic', 'bar'])
|
fetch = Sidekiq::BasicFetch.new(:queues => ['basic', 'bar'])
|
||||||
uow = fetch.retrieve_work
|
uow = fetch.retrieve_work
|
||||||
|
|
|
@ -5,6 +5,7 @@ class TestManager < Sidekiq::Test
|
||||||
|
|
||||||
describe 'manager' do
|
describe 'manager' do
|
||||||
before do
|
before do
|
||||||
|
Sidekiq.redis = REDIS
|
||||||
Sidekiq.redis {|c| c.flushdb }
|
Sidekiq.redis {|c| c.flushdb }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class TestWeb < Sidekiq::Test
|
||||||
|
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
refute conn.smembers('queues').include?('foo')
|
refute conn.smembers('queues').include?('foo')
|
||||||
refute conn.exists('queues:foo')
|
refute conn.exists('queue:foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue