Sha256: 4e4e36bb637f6066624d846a853be6a90cca30f2f3a17bdcdc87c5f45782f6a3
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
require 'foreman_tasks_test_helper' module ForemanTasks class RemoteTaskTest < ActiveSupport::TestCase describe 'batch triggering' do let(:remote_tasks) do (1..5).map do |i| task = RemoteTask.new :execution_plan_id => i, :step_id => 1, :proxy_url => "something" task.expects(:proxy_input).returns({}) task.expects(:proxy_action_name).returns('MyProxyAction') task.save! task end end it 'triggers in batches' do results = remote_tasks.reduce({}) do |acc, cur| acc.merge(cur.execution_plan_id.to_s => { 'task_id' => cur.id + 5, 'result' => 'success' }) end fake_proxy = mock fake_proxy.expects(:launch_tasks).returns(results) remote_tasks.first.expects(:proxy).returns(fake_proxy) RemoteTask.batch_trigger('a_operation', remote_tasks) remote_tasks.each do |remote_task| remote_task.reload _(remote_task.state).must_equal 'triggered' _(remote_task.remote_task_id).must_equal((remote_task.id + 5).to_s) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems