Sha256: 68b22c9166d20a0d962763203f0c16ca0d7c1b0888b9d72279a9ea080d60050a

Contents?: true

Size: 1.66 KB

Versions: 28

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

class PreupgradeReportTest < ActiveSupport::TestCase
  should belong_to(:job_invocation)
  should have_many(:preupgrade_report_entries).dependent(:destroy)

  describe '#create_report' do
    let(:job_invocation) { FactoryBot.create(:job_invocation) }
    let(:host) { FactoryBot.create(:host) }

    it 'with commands and hints' do
      data = { 'leapp_run_id' => 'leapp_c13e471c',
               'entries' => [sample_entry_1, sample_entry_2] }

      assert_difference -> { PreupgradeReport.count } => 1, -> { PreupgradeReportEntry.count } => 2 do
        PreupgradeReport.create_report(host, data, job_invocation)
      end
    end

    it 'no entries' do
      data = { 'leapp_run_id' => 'leapp_c13e471c' }

      assert_difference -> { PreupgradeReport.count } => 1, -> { PreupgradeReportEntry.count } => 0 do
        PreupgradeReport.create_report(host, data, job_invocation)
      end
    end
  end

  def sample_entry_1
    { 'severity' => 'low', 'title' => 'SElinux will be set to permissive mode',
      'tags' => %w[selinux security], 'actor' => 'check_se_linux',
      'summary' => 'sum', 'audience' => 'sysadmin', 'id' => 'id1' }
  end

  def sample_entry_2
    { 'severity' => 'high', 'tags' => ['kernel'], 'title' => 'Multiple devel kernels installed',
      'detail' => { 'remediations' => [
        { 'type' => 'hint', 'context' => 'Some context' },
        { 'type' => 'command', 'context' => ['yum', '-y', 'remove', 'kernel-devel-3.10.0.1127.el7'] }
      ] },
      'actor' => 'check_installed_devel_kernels', 'summary' => 'Sum', 'audience' => 'sysadmin',
      'flags' => ['inhibitor'], 'id' => 'id2' }
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
foreman_leapp-2.0.1 test/models/preupgrade_report_test.rb
foreman_leapp-2.0.0 test/models/preupgrade_report_test.rb
foreman_leapp-1.2.1 test/models/preupgrade_report_test.rb
foreman_leapp-1.2.0 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.15 test/models/preupgrade_report_test.rb
foreman_leapp-1.1.1 test/models/preupgrade_report_test.rb
foreman_leapp-1.1.0 test/models/preupgrade_report_test.rb
foreman_leapp-1.0.0 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.14 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.13 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.12 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.11 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.10 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.9 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.8 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.7 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.6 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.5 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.4 test/models/preupgrade_report_test.rb
foreman_leapp-0.1.3 test/models/preupgrade_report_test.rb