Sha256: 6a3475c3bd76a33ff4b3b8682be466040c38fe274c2ed2696f76a7473ec32229

Contents?: true

Size: 1.87 KB

Versions: 11

Compression:

Stored size: 1.87 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
      Setting::RemoteExecution.load_defaults
      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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_remote_execution-4.8.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.6 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.5 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.4 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.7.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.3 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.2 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.1 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.6.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.5.0 test/helpers/remote_execution_helper_test.rb
foreman_remote_execution-4.4.0 test/helpers/remote_execution_helper_test.rb