Sha256: 4a314f15ed38c0d06ec01e9fc57276d2ce8b026bd176eceae8193dffdaa301a6

Contents?: true

Size: 1.02 KB

Versions: 22

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../../_lib'))

require 'einhorn'

class WorkerPoolTest < EinhornTestCase
  def stub_children
    Einhorn::State.stubs(:children).returns(
      1234 => {:type => :worker, :signaled => Set.new(['INT'])},
      1235 => {:type => :state_passer},
      1236 => {:type => :worker, :signaled => Set.new}
      )
  end

  describe "#workers_with_state" do
    before do
      stub_children
    end

    it "selects only the workers" do
      workers_with_state = Einhorn::WorkerPool.workers_with_state
      # Sort only needed for Ruby 1.8
      assert_equal([
          [1234, {:type => :worker, :signaled => Set.new(['INT'])}],
          [1236, {:type => :worker, :signaled => Set.new}]
        ], workers_with_state.sort)
    end
  end

  describe "#unsignaled_workers" do
    before do
      stub_children
    end

    it "selects unsignaled workers" do
      unsignaled_workers = Einhorn::WorkerPool.unsignaled_workers
      assert_equal([1236], unsignaled_workers)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
einhorn-0.8.2 test/unit/einhorn/worker_pool.rb
einhorn-0.7.4 test/unit/einhorn/worker_pool.rb
einhorn-0.7.3 test/unit/einhorn/worker_pool.rb
einhorn-0.7.2 test/unit/einhorn/worker_pool.rb
einhorn-0.7.1 test/unit/einhorn/worker_pool.rb
einhorn-0.7.0 test/unit/einhorn/worker_pool.rb
einhorn-0.6.5 test/unit/einhorn/worker_pool.rb
einhorn-0.6.4 test/unit/einhorn/worker_pool.rb
einhorn-0.6.3 test/unit/einhorn/worker_pool.rb
einhorn-0.6.2 test/unit/einhorn/worker_pool.rb
einhorn-0.6.1 test/unit/einhorn/worker_pool.rb
einhorn-0.6.0 test/unit/einhorn/worker_pool.rb
einhorn-0.5.7 test/unit/einhorn/worker_pool.rb
einhorn-0.5.6 test/unit/einhorn/worker_pool.rb
einhorn-0.5.5 test/unit/einhorn/worker_pool.rb
einhorn-0.5.4 test/unit/einhorn/worker_pool.rb
einhorn-0.5.3 test/unit/einhorn/worker_pool.rb
einhorn-0.5.2 test/unit/einhorn/worker_pool.rb
einhorn-0.5.1 test/unit/einhorn/worker_pool.rb
einhorn-0.5.0 test/unit/einhorn/worker_pool.rb