Sha256: 742303aac41d95ab976edfe645da8a18241307162a44a1562ce8a64529e76189
Contents?: true
Size: 1.57 KB
Versions: 5
Compression:
Stored size: 1.57 KB
Contents
require "test_plugin_helper" module ForemanRemoteExecution class RunHostsJobTest < ActiveSupport::TestCase include Dynflow::Testing let(:host) { FactoryGirl.create(:host, :with_execution) } let(:proxy) { host.remote_execution_proxies('Ssh')[:subnet].first } let(:targeting) { FactoryGirl.create(:targeting, :search_query => "name = #{host.name}", :user => User.current) } let(:job_invocation) do FactoryGirl.build(:job_invocation, :with_template).tap do |invocation| invocation.targeting = targeting invocation.save end end let(:action) do action = create_action(Actions::RemoteExecution::RunHostsJob) action.expects(:action_subject).with(job_invocation) ForemanTasks::Task::DynflowTask.stubs(:find_by_external_id!).returns(OpenStruct.new(:id => '123')) plan_action(action, job_invocation) end before do ProxyAPI::ForemanDynflow::DynflowProxy.any_instance.stubs(:tasks_count).returns(0) User.current = users :admin action end it 'resolves the hosts on targeting in plan phase' do targeting.hosts.must_include(host) end it 'triggers the RunHostJob actions on the resolved hosts in run phase' do template_invocation = job_invocation.template_invocation_for_host(host) action.expects(:trigger).with(Actions::RemoteExecution::RunHostJob, job_invocation, host, template_invocation, proxy, {}) action.create_sub_plans end it 'uses the BindJobInvocation middleware' do action job_invocation.last_task_id.must_equal '123' end end end
Version data entries
5 entries across 5 versions & 1 rubygems