Sha256: 211f69fdeb7efdf64b5d2da10f1103ce649490410e38c2efaf78d9ac461d02da

Contents?: true

Size: 1000 Bytes

Versions: 8

Compression:

Stored size: 1000 Bytes

Contents

require 'helper'
require 'sidekiq'
require 'sidekiq/manager'

# for TimedQueue
require 'connection_pool'

class TestManager < MiniTest::Unit::TestCase
  describe 'with redis' do
    before do
      Sidekiq.redis = REDIS
      Sidekiq.redis {|c| c.flushdb }
      $processed = 0
      $mutex = Mutex.new
    end

    class IntegrationWorker
      include Sidekiq::Worker

      def perform(a, b)
        $mutex.synchronize do
          $processed += 1
        end
        a + b
      end
    end

    it 'processes messages' do
      Sidekiq::Client.push('queue' => :foo, 'class' => IntegrationWorker, 'args' => [1, 2])
      Sidekiq::Client.push('queue' => :foo, 'class' => IntegrationWorker, 'args' => [1, 3])

      q = TimedQueue.new
      mgr = Sidekiq::Manager.new(:queues => [:foo], :concurrency => 2)
      mgr.when_done do |_|
        q << 'done' if $processed == 2
      end
      mgr.start!
      result = q.timed_pop(1.0)
      assert_equal 'done', result
      mgr.stop
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-1.1.3 test/test_manager.rb
sidekiq-1.1.2 test/test_manager.rb
sidekiq-1.1.1 test/test_manager.rb
sidekiq-1.1.0 test/test_manager.rb
sidekiq-1.0.0 test/test_manager.rb
sidekiq-0.11.2 test/test_manager.rb
sidekiq-0.11.1 test/test_manager.rb
sidekiq-0.11.0 test/test_manager.rb