Skip to content

Commit

Permalink
Update packages update all warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Jun 13, 2024
1 parent 20cdd9f commit 135d61a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
17 changes: 12 additions & 5 deletions definitions/procedures/packages/update_all_confirmation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ class UpdateAllConfirmation < ForemanMaintain::Procedure

def run
if @packages.nil? || @packages.empty?
question = "\nWARNING: No specific packages to update were provided\n" \
"so we are going to update all available packages.\n" \
"To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
"Do you want to proceed with update of everything regardless\n" \
'of the recommendations?'
command = ForemanMaintain.command_name

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using '#{command} update'.
To upgrade to the next #{feature(:instance).product_name} version use '#{command} upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
abort! unless answer == :yes
end
Expand Down
4 changes: 4 additions & 0 deletions lib/foreman_maintain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ def pkg_and_cmd_name
[main_package_name, 'foreman-maintain']
end

def command_name
pkg_and_cmd_name[1]
end

def perform_self_upgrade
package_name, command = pkg_and_cmd_name

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'test_helper'
require_relative '../../test_helper'
require_relative '../../../../definitions/procedures/packages/update_all_confirmation'

describe Procedures::Packages::UpdateAllConfirmation do
include ::DefinitionsTestHelper

def skip_mock_package_manager
true
end

subject do
Procedures::Packages::UpdateAllConfirmation.new
end

it 'contains the proper message for Foreman' do
assume_feature_present(:foreman_install)

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using 'foreman-maintain update'.
To upgrade to the next Foreman version use 'foreman-maintain upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes)

run_procedure(subject)
end

it 'contains the proper message for Satellite' do
assume_feature_present(:satellite)

question = <<~MSG
WARNING: No specific packages to update were provided
so we are going to update all available packages. We
recommend using the update command to update to a minor
version and/or operating system using 'satellite-maintain update'.
To upgrade to the next Satellite version use 'satellite-maintain upgrade'.
Do you want to proceed with update of everything regardless of
the recommendations?
MSG

subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes)

run_procedure(subject)
end
end

0 comments on commit 135d61a

Please sign in to comment.