Sha256: e0442e305c429c0fd24c19e4e145fe4225af5cd2d8f3dcb9208804a5ab0c163d

Contents?: true

Size: 1.42 KB

Versions: 20

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

module ForemanLeapp
  class PreupgradeJobTest < ActiveSupport::TestCase
    include Dynflow::Testing

    let(:host) { FactoryBot.create(:host) }
    let(:job_template) do
      FactoryBot.create(:job_template, template: 'echo "1"', job_category: 'leapp',
                                       provider_type: 'SSH', name: 'Leapp preupgrade')
    end
    let(:job_invocation) { FactoryBot.create(:job_invocation) }
    let(:template_invocation) do
      FactoryBot.create(:template_invocation, template: job_template, job_invocation: job_invocation)
    end

    let(:action) { create_action(Actions::ForemanLeapp::PreupgradeJob) }
    let(:planned_action) { plan_action(action, job_invocation, host, template_invocation) }

    setup do
      RemoteExecutionFeature.find_by(label: 'leapp_preupgrade').update(job_template: job_template)
    end

    describe 'plan' do
      test 'run plan phase' do
        assert_equal planned_action.input['host_id'], host.id
        assert_equal planned_action.input['job_invocation_id'], job_invocation.id
      end
    end

    describe '#format_output' do
      let(:output) { "first_line\n===leap_upgrade_report_start===\n{\n\"report\": \"yes!\"\n}\nExit status: 0\n" }

      it { assert action.send(:format_output, output), '{"report": "yes!"}' }
    end

    describe 'finalize' do
      it { assert_finalize_phase planned_action }
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman_leapp-1.2.3 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.2.2 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.2.1 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.2.0 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.15 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.1.1 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.1.0 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-1.0.0 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.14 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.13 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.12 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.11 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.10 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.9 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.8 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.7 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.6 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.5 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.4 test/unit/actions/preupgrade_job_test.rb
foreman_leapp-0.1.3 test/unit/actions/preupgrade_job_test.rb