Sha256: 54b9df9e7d4e845c321663260f50f687185b2a4bab38e1252d7841745c4239c8

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

require 'test_plugin_helper'

describe RemoteExecutionFeature do

  let(:install_feature) do
    RemoteExecutionFeature.register(:katello_install_package, N_('Katello: Install package'),
                                    :description => 'Install package via Katello user interface',
                                    :provided_inputs => ['package'])
  end

  let(:package_template) do
    FactoryGirl.create(:job_template).tap do |job_template|
      job_template.job_category = 'Package Action'
      job_template.name = 'Package Action - SSH Default'
      job_template.template_inputs.create(:name => 'package', :input_type => 'user')
    end
  end

  let(:host) { FactoryGirl.create(:host) }

  before do
    User.current = users :admin
    install_feature.update_attributes!(:job_template_id => package_template.id)
  end

  describe 'composer' do
    it 'prepares composer for given feature based on the mapping' do
      composer = JobInvocationComposer.for_feature(:katello_install_package, host, :package => 'zsh')
      assert composer.valid?
      composer.pattern_template_invocations.size.must_equal 1
      template_invocation = composer.pattern_template_invocations.first
      template_invocation.template.must_equal package_template
      template_invocation.input_values.size.must_equal 1

      input_value = template_invocation.input_values.first
      input_value.value.must_equal 'zsh'
      input_value.template_input.name.must_equal 'package'

      composer.targeting.search_query.must_equal "name = #{host.name}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_remote_execution-0.3.2 test/unit/remote_execution_feature_test.rb
foreman_remote_execution-0.3.1 test/unit/remote_execution_feature_test.rb
foreman_remote_execution-0.3.0 test/unit/remote_execution_feature_test.rb