Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Feb 13, 2019
1 parent 2e0b21d commit 4f9acdd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/y2packager/system_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class SystemPackages
#
# Constructor
#
# @param repository_urls [Array<String>] Repositories from which the driver packages should be selected
# @param repository_urls [Array<String>] Repositories from which the driver
# packages should be selected
#
def initialize(repository_urls)
log.info "System packages repositories: #{repository_urls.inspect}"
Expand Down
51 changes: 51 additions & 0 deletions test/system_packages_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env rspec

require_relative "test_helper"
require "y2packager/system_packages"

describe Y2Packager::SystemPackages do
Yast.import "Pkg"

let(:repo_url) { "http://example.com/repo" }
let(:repos) { [repo_url] }
let(:source_id) { 42 }
let(:system_package) { "system_package" }

subject do
Y2Packager::SystemPackages.new(repos)
end

describe "#packages" do
it "returns the packages from the new repository" do
allow(Yast::Pkg).to receive(:SourceGetCurrent).and_return([source_id])
allow(Yast::Pkg).to receive(:SourceGeneralData).and_return("url" => repo_url)
allow(Yast::Pkg).to receive(:GetSolverFlags)
allow(Yast::Pkg).to receive(:PkgSolve)
allow(Yast::Pkg).to receive(:SetSolverFlags)
allow(Yast::Pkg).to receive(:ResolvableProperties).and_return(
[
"name" => system_package,
"source" => source_id,
"status" => :selected,
"transact_by" => :solver
]
)

expect(subject.packages).to eq(["system_package"])
end

it "returns empty list if repository list is empty" do
expect(Y2Packager::SystemPackages.new([]).packages).to eq([])
end
end

describe "#select" do
it "selects the system packages to install" do
allow(subject).to receive(:packages).and_return([system_package])
expect(Yast::Pkg).to receive(:PkgInstall).with(system_package)

subject.select
end
end

end

0 comments on commit 4f9acdd

Please sign in to comment.