From 89a1914d4540b034d5558ddf7821ebc99d297913 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 7 Oct 2015 15:01:44 -0700 Subject: [PATCH] Fix tests --- test/test_launcher.rb | 23 +++++------------------ test/test_processor.rb | 10 ++++------ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/test/test_launcher.rb b/test/test_launcher.rb index 476a254c..a9b722d2 100644 --- a/test/test_launcher.rb +++ b/test/test_launcher.rb @@ -9,31 +9,24 @@ class TestLauncher < Sidekiq::Test end def new_manager(opts) - condvar = Minitest::Mock.new - condvar.expect(:signal, nil, []) - Sidekiq::Manager.new(condvar, opts) + Sidekiq::Manager.new(nil, opts) end describe 'heartbeat' do before do uow = Object.new - @processor = Minitest::Mock.new - @processor.expect(:request_process, nil, [uow]) - @processor.expect(:hash, 1234, []) - @mgr = new_manager(options) @launcher = Sidekiq::Launcher.new(options) @launcher.manager = @mgr - @mgr.ready << @processor - @mgr.assign(uow) + Sidekiq::Processor::WORKER_STATE['a'] = {'b' => 1} - @processor.verify @proctitle = $0 end after do + Sidekiq::Processor::WORKER_STATE.clear $0 = @proctitle end @@ -58,23 +51,17 @@ class TestLauncher < Sidekiq::Test describe 'when manager is stopped' do before do - @processor.expect(:hash, 1234, []) - @processor.expect(:terminate, []) - @launcher.quiet - @launcher.manager.processor_done(@processor) @launcher.heartbeat('identity', heartbeat_data, Sidekiq.dump_json(heartbeat_data)) - - @processor.verify end it 'indicates stopping status in proctitle' do - assert_equal "sidekiq #{Sidekiq::VERSION} myapp [0 of 3 busy] stopping", $0 + assert_equal "sidekiq #{Sidekiq::VERSION} myapp [1 of 3 busy] stopping", $0 end it 'stores process info in redis' do info = Sidekiq.redis { |c| c.hmget('identity', 'busy') } - assert_equal ["0"], info + assert_equal ["1"], info expires = Sidekiq.redis { |c| c.pttl('identity') } assert_in_delta 60000, expires, 50 end diff --git a/test/test_processor.rb b/test/test_processor.rb index f73f09d0..40f651a3 100644 --- a/test/test_processor.rb +++ b/test/test_processor.rb @@ -172,10 +172,9 @@ class TestProcessor < Sidekiq::Test end it 'increments processed stat' do - assert_equal 0, Sidekiq::Stats.new.processed + Sidekiq::Processor::PROCESSED.value = 0 successful_job - assert_equal 1, Sidekiq::Stats.new.processed - assert_equal Sidekiq::Processor::STATS_TIMEOUT, Sidekiq.redis { |conn| conn.ttl(processed_today_key) } + assert_equal 1, Sidekiq::Processor::PROCESSED.value end end @@ -191,10 +190,9 @@ class TestProcessor < Sidekiq::Test end it 'increments failed stat' do - assert_equal 0, Sidekiq::Stats.new.failed + Sidekiq::Processor::FAILURE.value = 0 failed_job - assert_equal 1, Sidekiq::Stats.new.failed - assert_equal Sidekiq::Processor::STATS_TIMEOUT, Sidekiq.redis { |conn| conn.ttl(failed_today_key) } + assert_equal 1, Sidekiq::Processor::FAILURE.value end end end