Sha256: 0db3af6a1a8341afaa53a6a0493825b71b22277994442a9e8abe299116e5ef78

Contents?: true

Size: 1.95 KB

Versions: 101

Compression:

Stored size: 1.95 KB

Contents

require 'test_plugin_helper'

class TemplateInvocationInputTest < ActiveSupport::TestCase
  let(:template) { FactoryBot.build(:job_template, :template => 'service restart <%= input("service_name") -%>') }
  let(:renderer) { InputTemplateRenderer.new(template) }
  let(:job_invocation) { FactoryBot.create(:job_invocation) }
  let(:template_invocation) { FactoryBot.build(:template_invocation, :template => template) }
  let(:result) { renderer.render }

  context 'with selectable options' do
    before do
      result # let is lazy
      template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name', :input_type => 'user',
                                                                    :required => true, :options => "foreman\nhttpd")
    end

    it 'fails with an invalid option' do
      refute_valid FactoryBot.build(:template_invocation_input_value, :template_invocation => template_invocation,
                                                                      :template_input => template.template_inputs.first,
                                                                      :value => 'sendmail')
    end

    it 'succeeds with valid option' do
      assert_valid FactoryBot.build(:template_invocation_input_value, :template_invocation => template_invocation,
                                                                      :template_input => template.template_inputs.first,
                                                                      :value => 'foreman')
    end
  end

  it 'supports large inputs' do
    template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name',
                                                                  :input_type => 'user', :required => true)
    assert_valid FactoryBot.create(:template_invocation_input_value,
      :template_invocation => template_invocation,
      :template_input => template.template_inputs.first,
      :value => 'foreman' * 1_000_000)
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
foreman_remote_execution-15.0.0 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.1.4 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.1.3 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.1.2 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.1.1 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.0.2 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.0.1 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.6 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-14.0.0 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.5 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.4 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.3 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.2 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-12.0.7 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.1 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.2.0 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-10.1.3 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-13.0.0 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-12.0.5 test/unit/template_invocation_input_value_test.rb
foreman_remote_execution-12.0.4 test/unit/template_invocation_input_value_test.rb