Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
FROM yastdevel/ruby | ||
COPY . /usr/src/app | ||
|
||
RUN zypper -n in yast2-ntp-client | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env rspec | ||
|
||
require_relative "test_helper" | ||
|
||
require "yast" | ||
require_relative "../src/clients/add-on_auto" | ||
|
||
describe Yast::AddOnAutoClient do | ||
describe "#main" do | ||
before do | ||
allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func]) | ||
allow(Yast::WFM).to receive(:Args).with(0).and_return(func) | ||
end | ||
|
||
context "when 'func' arg is 'Write'" do | ||
let(:func) { "Write" } | ||
let(:repos) do | ||
[ | ||
{ | ||
"SrcId" => 1, | ||
"autorefresh" => true, | ||
"enabled" => true, | ||
"keeppackaged" => false, | ||
"name" => "repo_to_be_updated", | ||
"priority" => 99, | ||
"service" => "" | ||
}, | ||
{ | ||
"SrcId" => 2, | ||
"autorefresh" => true, | ||
"enabled" => true, | ||
"keeppackaged" => false, | ||
"name" => "untouched_repo", | ||
"priority" => 99, | ||
"service" => "" | ||
} | ||
] | ||
end | ||
|
||
before do | ||
allow(Yast::Pkg).to receive(:SourceEditSet) | ||
allow(Yast::AddOnProduct).to receive(:add_on_products).and_return(add_on_products) | ||
end | ||
|
||
context "and (product) source is loaded" do | ||
let(:add_on_products) do | ||
[ | ||
{ | ||
"alias" => "produc_alias", | ||
"media_url" => "http://product.url", | ||
"name" => "updated_repo", | ||
"priority" => 20, | ||
"product_dir" => "/" | ||
} | ||
] | ||
end | ||
let(:updated_repos) do | ||
[ | ||
{ | ||
"SrcId" => 1, | ||
"autorefresh" => true, | ||
"enabled" => true, | ||
"keeppackaged" => false, | ||
"name" => "updated_repo", | ||
"priority" => 20, | ||
"service" => "" | ||
}, | ||
{ | ||
"SrcId" => 2, | ||
"autorefresh" => true, | ||
"enabled" => true, | ||
"keeppackaged" => false, | ||
"name" => "untouched_repo", | ||
"priority" => 99, | ||
"service" => "" | ||
} | ||
] | ||
end | ||
|
||
before do | ||
allow(Yast::Pkg).to receive(:SourceCreate).and_return(1) | ||
allow(Yast::Pkg).to receive(:SourceEditGet).and_return(repos) | ||
end | ||
|
||
it "updates repos" do | ||
expect(Yast::Pkg).to receive(:SourceEditSet).with(updated_repos) | ||
|
||
subject.main | ||
end | ||
end | ||
end | ||
end | ||
end |