Sha256: c1ffbcebc3168e0d5d5f59b8add4bd7f898b26172047e4fc8d06d4cc5651ba84
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 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(:task) do OpenStruct.new(:id => '123').tap do |o| o.stubs(:add_missing_task_groups) o.stubs(:task_groups).returns([]) end end let(:action) do action = create_action(Actions::RemoteExecution::RunHostsJob) action.expects(:action_subject).with(job_invocation) ForemanTasks::Task::DynflowTask.stubs(:where).returns(mock.tap { |m| m.stubs(:first! => task) }) 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 action.expects(:trigger).with() { |*args| args[0] == Actions::RemoteExecution::RunHostJob } action.create_sub_plans end it 'uses the BindJobInvocation middleware' do action job_invocation.task_id.must_equal '123' end end end
Version data entries
3 entries across 3 versions & 1 rubygems