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
|
||||
include Util
|
||||
include Singleton
|
||||
include Singleton unless $TESTING
|
||||
|
||||
# Used for CLI testing
|
||||
attr_accessor :code
|
||||
|
|
|
@ -261,7 +261,7 @@ class TestApi < Sidekiq::Test
|
|||
|
||||
Sidekiq.redis do |conn|
|
||||
refute conn.smembers('queues').include?('foo')
|
||||
refute conn.exists('queues:foo')
|
||||
refute conn.exists('queue:foo')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,20 +2,26 @@ require 'helper'
|
|||
require 'sidekiq/cli'
|
||||
require 'tempfile'
|
||||
|
||||
cli = Sidekiq::CLI.instance
|
||||
def cli.die(code)
|
||||
@code = code
|
||||
end
|
||||
class Sidekiq::CLI
|
||||
def die(code)
|
||||
@code = code
|
||||
end
|
||||
|
||||
def cli.valid?
|
||||
!@code
|
||||
def valid?
|
||||
!@code
|
||||
end
|
||||
end
|
||||
|
||||
class TestCli < Sidekiq::Test
|
||||
describe 'CLI#parse' do
|
||||
|
||||
before do
|
||||
@cli = Sidekiq::CLI.instance
|
||||
@cli = Sidekiq::CLI.new
|
||||
@opts = Sidekiq.options.dup
|
||||
end
|
||||
|
||||
after do
|
||||
Sidekiq.options = @opts
|
||||
end
|
||||
|
||||
it 'does not require the specified Ruby code' do
|
||||
|
|
|
@ -24,7 +24,7 @@ class TestClient < Sidekiq::Test
|
|||
end
|
||||
|
||||
after do
|
||||
Sidekiq.instance_variable_set(:@redis, REDIS)
|
||||
Sidekiq.redis = REDIS
|
||||
Sidekiq::Client.instance_variable_set(:@default, nil)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ class TestFetcher < Sidekiq::Test
|
|||
end
|
||||
end
|
||||
|
||||
after do
|
||||
Sidekiq.redis = REDIS
|
||||
end
|
||||
|
||||
it 'retrieves' do
|
||||
fetch = Sidekiq::BasicFetch.new(:queues => ['basic', 'bar'])
|
||||
uow = fetch.retrieve_work
|
||||
|
|
|
@ -5,6 +5,7 @@ class TestManager < Sidekiq::Test
|
|||
|
||||
describe 'manager' do
|
||||
before do
|
||||
Sidekiq.redis = REDIS
|
||||
Sidekiq.redis {|c| c.flushdb }
|
||||
end
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class TestWeb < Sidekiq::Test
|
|||
|
||||
Sidekiq.redis do |conn|
|
||||
refute conn.smembers('queues').include?('foo')
|
||||
refute conn.exists('queues:foo')
|
||||
refute conn.exists('queue:foo')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue