Skip to content

Commit

Permalink
Handle storage proposal exceptions in a proper way
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 7, 2017
1 parent d6e8c8b commit 5669931
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/autoinstall/storage_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def handle_exception(error)
when Y2Storage::NoDiskSpaceError
issues_list.add(:no_disk_space)
when Y2Storage::Error
issues_list.add(:unknown, error)
issues_list.add(:exception, error)
else
raise error
end
Expand Down
12 changes: 12 additions & 0 deletions test/lib/storage_proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
expect(storage_proposal.proposal).to be(autoinst_proposal)
end
end

context "when the proposal raises and exception" do
before do
allow(autoinst_proposal).to receive(:propose).and_raise(Y2Storage::Error)
end

it "registers an issue" do
issues_list = storage_proposal.issues_list
issue = issues_list.find { |i| i.is_a?(Y2Storage::AutoinstIssues::Exception) }
expect(issue).to_not be_nil
end
end
end

describe "#save" do
Expand Down

0 comments on commit 5669931

Please sign in to comment.