Skip to content

Commit

Permalink
Add a basic test case for packages proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 30, 2017
1 parent 5ed8613 commit b151d91
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ TESTS = \
root_part_test.rb \
suse_release_test.rb \
inst_update_partition_auto_test.rb \
packages_proposal_test.rb \
update_test.rb

TEST_EXTENSIONS = .rb
Expand Down
57 changes: 57 additions & 0 deletions test/packages_proposal_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env rspec

require_relative "test_helper"
require_relative "../src/clients/packages_proposal"

describe Yast::PackagesProposalClient do
subject(:client) { described_class.new }

before do
allow(Yast::WFM).to receive(:Args) do |n|
n.nil? ? args : args[n]
end
end

describe "#main" do
context "when action is MakeProposal" do
let(:args) { ["MakeProposal"] }

PACKAGES = {
installed: ["grub", "elilo"],
selected: ["grub", "grub2-efi", "grub2-pc"],
removed: ["elilo"]
}

before do
allow(Yast::SpaceCalculation).to receive(:GetPartitionWarning)
.and_return(nil)
allow(Yast::Packages).to receive(:proposal_for_update)
allow(Yast::Pkg).to receive(:GetPackages).with(anything, true) do |status, _names_only|
PACKAGES[status]
end
end

it "asks for a packages selection proposal" do
expect(Yast::Packages).to receive(:proposal_for_update)
client.main
end

it "summarizes packages to update/install/remove" do
expect(Yast::Update).to receive(:packages_to_update=)
.with(1)
expect(Yast::Update).to receive(:packages_to_install=)
.with(2)
expect(Yast::Update).to receive(:packages_to_remove=)
.with(1)
client.main
end

it "is meant to be triggered if packages proposal changes" do
expect(client.main["trigger"]).to eq({
"expect" => { "class" => "Yast::Packages", "method" => "PackagesProposalChanged" },
"value" => false
})
end
end
end
end

0 comments on commit b151d91

Please sign in to comment.