From 9fcf0610c0813d47584aa0dec0152acdb47a071d Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 24 Oct 2024 15:52:59 +0200 Subject: [PATCH] storage: do not register issues when skipping entries at the config --- service/lib/agama/storage/config_checker.rb | 21 ++----------------- .../test/agama/storage/config_checker_test.rb | 20 +++++------------- .../y2storage/agama_proposal_search_test.rb | 7 ++----- service/test/y2storage/agama_proposal_test.rb | 16 +++++--------- 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/service/lib/agama/storage/config_checker.rb b/service/lib/agama/storage/config_checker.rb index cead5a632..666e4d7ac 100644 --- a/service/lib/agama/storage/config_checker.rb +++ b/service/lib/agama/storage/config_checker.rb @@ -81,15 +81,10 @@ def drive_issues(config) # @return [Agama::Issue] def search_issue(config) return if !config.search || config.found_device + return if config.search.skip_device? if config.is_a?(Agama::Storage::Configs::Drive) - if config.search.skip_device? - warning(_("No device found for an optional drive")) - else - error(_("No device found for a mandatory drive")) - end - elsif config.search.skip_device? - warning(_("No device found for an optional partition")) + error(_("No device found for a mandatory drive")) else error(_("No device found for a mandatory partition")) end @@ -470,18 +465,6 @@ def volume_builder @volume_builder ||= VolumeTemplatesBuilder.new_from_config(product_config) end - # Creates a warning issue. - # - # @param message [String] - # @return [Issue] - def warning(message) - Agama::Issue.new( - message, - source: Agama::Issue::Source::CONFIG, - severity: Agama::Issue::Severity::WARN - ) - end - # Creates an error issue. # # @param message [String] diff --git a/service/test/agama/storage/config_checker_test.rb b/service/test/agama/storage/config_checker_test.rb index fa2da3bb5..6efdf161e 100644 --- a/service/test/agama/storage/config_checker_test.rb +++ b/service/test/agama/storage/config_checker_test.rb @@ -21,7 +21,7 @@ require_relative "./storage_helpers" require "agama/config" -require "agama/storage/config_conversions/from_json" +require "agama/storage/config_conversions" require "agama/storage/config_checker" require "agama/storage/config_solver" require "y2storage" @@ -281,13 +281,8 @@ context "and the drive should be skipped" do let(:if_not_found) { "skip" } - it "includes the expected issue" do - issues = subject.issues - expect(issues.size).to eq(1) - - issue = issues.first - expect(issue.error?).to eq(false) - expect(issue.description).to eq("No device found for an optional drive") + it "does not include any issue" do + expect(subject.issues).to be_empty end end @@ -374,13 +369,8 @@ context "and the partition should be skipped" do let(:if_not_found) { "skip" } - it "includes the expected issue" do - issues = subject.issues - expect(issues.size).to eq(1) - - issue = issues.first - expect(issue.error?).to eq(false) - expect(issue.description).to eq("No device found for an optional partition") + it "does not include any issue" do + expect(subject.issues).to be_empty end end diff --git a/service/test/y2storage/agama_proposal_search_test.rb b/service/test/y2storage/agama_proposal_search_test.rb index 80a4dd670..6344aca0c 100644 --- a/service/test/y2storage/agama_proposal_search_test.rb +++ b/service/test/y2storage/agama_proposal_search_test.rb @@ -207,12 +207,9 @@ expect(disk.partitions.size).to eq 1 end - it "register a warning about non-existent partitions" do + it "register a no issues about non-existent partitions" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional partition/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end end diff --git a/service/test/y2storage/agama_proposal_test.rb b/service/test/y2storage/agama_proposal_test.rb index d26db503d..bc818c2e2 100644 --- a/service/test/y2storage/agama_proposal_test.rb +++ b/service/test/y2storage/agama_proposal_test.rb @@ -22,7 +22,7 @@ require_relative "../agama/storage/storage_helpers" require "agama/config" require "agama/storage/config" -require "agama/storage/config_conversions/from_json" +require "agama/storage/config_conversions" require "y2storage" require "y2storage/agama_proposal" @@ -484,12 +484,9 @@ def partition_config(name: nil, filesystem: nil, size: nil) expect(proposal.failed?).to eq false end - it "registers a non-critical issue" do + it "does not register any issue about missing disks" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional drive/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end @@ -576,12 +573,9 @@ def partition_config(name: nil, filesystem: nil, size: nil) expect(proposal.failed?).to eq false end - it "registers a non-critical issue" do + it "does not register any issue about missing partitions" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional partition/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end