Sha256: 03a8f497d5f3a3c16bdb807e7e2d5bfe664bca9c791565bde36dcd2aeab14b5d

Contents?: true

Size: 1.49 KB

Versions: 49

Compression:

Stored size: 1.49 KB

Contents

require 'foreman_tasks_core_test_helper'
require 'foreman_tasks/test_helpers'
require 'foreman_tasks_core/runner'

module ForemanTasksCore
  module Runner
    describe Dispatcher::RunnerActor do
      include ForemanTasks::TestHelpers::WithInThreadExecutor

      let(:dispatcher) { Dispatcher.instance }
      let(:suspended_action) { mock }
      let(:runner) { mock.tap { |r| r.stubs(:id) } }
      let(:clock) { ForemanTasks.dynflow.world.clock }
      let(:logger) { mock.tap { |l| l.stubs(:debug) } }
      let(:actor) do
        Dispatcher::RunnerActor.new dispatcher, suspended_action, runner, clock, logger
      end

      it 'delivers all updates to actions' do
        targets = (0..2).map { mock }.each_with_index { |mock, index| mock.expects(:<<).with(index) }
        updates = targets.each_with_index.reduce({}) { |acc, (cur, index)| acc.merge(cur => index) }
        runner.expects(:run_refresh).returns(updates)
        actor.expects(:plan_next_refresh)
        actor.refresh_runner
      end

      it 'plans next refresh' do
        runner.expects(:run_refresh).returns({})
        actor.expects(:plan_next_refresh)
        actor.refresh_runner
      end

      it 'does not plan next resfresh if done' do
        update = Update.new(nil, 0)
        suspended_action.expects(:<<).with(update)
        runner.expects(:run_refresh).returns(suspended_action => update)
        dispatcher.expects(:finish)
        dispatcher.ticker.expects(:tell).never
        actor.refresh_runner
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
foreman-tasks-4.1.6 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.5 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.4 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.3 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.6 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.2 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.1 test/core/unit/dispatcher_test.rb
foreman-tasks-4.0.1 test/core/unit/dispatcher_test.rb
foreman-tasks-4.1.0 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.5 test/core/unit/dispatcher_test.rb
foreman-tasks-4.0.0 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.4 test/core/unit/dispatcher_test.rb
foreman-tasks-2.0.3 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.3 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.2 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.1 test/core/unit/dispatcher_test.rb
foreman-tasks-3.0.0 test/core/unit/dispatcher_test.rb
foreman-tasks-2.0.2 test/core/unit/dispatcher_test.rb
foreman-tasks-1.1.3 test/core/unit/dispatcher_test.rb
foreman-tasks-1.1.2 test/core/unit/dispatcher_test.rb