Skip to content

Commit

Permalink
storage: do not register issues when skipping entries at the config
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Oct 24, 2024
1 parent 825ad0c commit 9fcf061
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 50 deletions.
21 changes: 2 additions & 19 deletions service/lib/agama/storage/config_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
20 changes: 5 additions & 15 deletions service/test/agama/storage/config_checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
7 changes: 2 additions & 5 deletions service/test/y2storage/agama_proposal_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions service/test/y2storage/agama_proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9fcf061

Please sign in to comment.