Sha256: a3fa41a3480e5c1e0975f307a21f9ca92b1b381c582d764d4963f36bc0cca778

Contents?: true

Size: 1.93 KB

Versions: 35

Compression:

Stored size: 1.93 KB

Contents

require 'test_plugin_helper'

class RemoteExecutionHelperTest < ActionView::TestCase
  describe '#normalize_line_sets' do
    let :line_sets do
      [{"output_type"=>"stdout", "output"=>"one", "timestamp"=>1},
       {"output_type"=>"stdout", "output"=>"\r\ntwo\r\n", "timestamp"=>2},
       {"output_type"=>"stdout", "output"=>"\r\nthr", "timestamp"=>3},
       {"output_type"=>"stdout", "output"=>"ee\r\nfour\r\n", "timestamp"=>4},
       {"output_type"=>"stdout", "output"=>"\r\n\r\n", "timestamp"=>5},
       {"output_type"=>"stdout", "output"=>"five\r\n", "timestamp"=>6},
       {"output_type"=>"stdout", "output"=>"Exit status: 0", "timestamp"=>7}]
    end

    it 'ensures the line sets end with new line' do
      new_line_sets = normalize_line_sets(line_sets)
      new_line_sets.map { |s| s['output'] }.must_equal(["one\r\n",
                                                        "two\r\n",
                                                        "\r\nthree\r\n",
                                                        "four\r\n",
                                                        "\r\n\r\n",
                                                        "five\r\n",
                                                        "Exit status: 0"])
    end
  end

  describe 'test correct setting' do
    it 'should found correct template from setting' do
      template_name = 'Job Invocation Report Template'
      setting_key = 'remote_execution_job_invocation_report_template'
      template = FactoryBot.create(:report_template, name: template_name)
      input = FactoryBot.create(:template_input, name: 'job_id', input_type: 'user')
      template.template_inputs << input
      Setting.expects(:[]).with(setting_key).returns(template_name)

      found_template = job_report_template

      assert_equal template.id, found_template.id
    end

    it 'should not crash if the template cannot be found' do
      assert_nil job_report_template
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
foreman_remote_execution-12.0.7 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.1.3 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-12.0.5 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-12.0.4 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-12.0.1 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-12.0.2 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-11.1.3 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.1.2 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-12.0.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.1.1 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-11.1.1 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-11.1.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.1.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-8.3.3 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-8.3.2 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-11.0.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.0.7 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-8.3.1 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.0.6 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-10.0.5 test/helpers/remote_execution_helper_test.rb