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
Vladimir Moravec
committed
Dec 13, 2013
1 parent
2741887
commit 2f2be06
Showing
4 changed files
with
64 additions
and
33 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,43 +1,35 @@ | ||
module ZyppConfiguration | ||
class ZyppConfig | ||
SCR_TARGET = '.etc.zypp_conf' | ||
CONFIG_USE_DELTA_RPM = "#{SCR_TARGET}.value.main.\"download.use_deltarpm\"" | ||
|
||
def zypp_config | ||
@config ||= ZyppConfig.new | ||
def initialize | ||
current_config = get_delta_rpm_config_value | ||
# Default config for delta rpms in zypp.conf is true | ||
@use_delta_rpm = current_config == nil || current_config == 'true' | ||
end | ||
|
||
class ZyppConfig | ||
def initialize | ||
current_config = delta_rpm_config_value | ||
# Default settings in zypp.conf for using delta rpms is true | ||
@use_delta_rpm = current_config == nil || current_config == 'true' | ||
end | ||
|
||
def use_delta_rpm? | ||
@use_delta_rpm | ||
end | ||
def use_delta_rpm? | ||
@use_delta_rpm | ||
end | ||
|
||
def activate_delta_rpm | ||
Yast::Builtins.y2milestone("Activating delta rpms for online update..") | ||
set_config_value(true) | ||
end | ||
def activate_delta_rpm | ||
Yast::Builtins.y2milestone("Activating delta rpms for online update..") | ||
set_delta_rpm_config_value(true) | ||
end | ||
|
||
def deactivate_delta_rpm | ||
Yast::Builtins.y2milestone("Deactivating delta rpms for online update..") | ||
set_config_value(false) | ||
end | ||
def deactivate_delta_rpm | ||
Yast::Builtins.y2milestone("Deactivating delta rpms for online update..") | ||
set_delta_rpm_config_value(false) | ||
end | ||
|
||
private | ||
private | ||
|
||
def set_config_value new_value | ||
return if new_value == use_delta_rpm? | ||
Yast::SCR.Write(Yast::Path.new(CONFIG_USE_DELTA_RPM), new_value) | ||
end | ||
def set_delta_rpm_config_value new_value | ||
return if new_value == use_delta_rpm? | ||
Yast::SCR.Write(Yast::Path.new(CONFIG_USE_DELTA_RPM), new_value) | ||
end | ||
|
||
def delta_rpm_config_value | ||
Yast::Builtins.y2milestone("Reading zypp configuration for deltarpms") | ||
Yast::SCR.Read(Yast::Path.new(CONFIG_USE_DELTA_RPM)) | ||
end | ||
def get_delta_rpm_config_value | ||
Yast::SCR.Read(Yast::Path.new(CONFIG_USE_DELTA_RPM)) | ||
end | ||
end | ||
|
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,6 @@ | ||
require 'rspec' | ||
|
||
ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) | ||
|
||
require 'yast' | ||
require 'online-update-configuration/zypp_config' |
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,33 @@ | ||
#!/usr/bin/env rspec | ||
|
||
require_relative 'test_helper' | ||
|
||
describe ZyppConfig do | ||
attr_reader :config | ||
|
||
it "provides config value for delta rpms if explicitly activated" do | ||
ZyppConfig.any_instance.stub(:get_delta_rpm_config_value).and_return('true') | ||
expect(ZyppConfig.new.use_delta_rpm?).to eq(true) | ||
end | ||
|
||
it "provides config value for delta rpms if using default settings" do | ||
ZyppConfig.any_instance.stub(:get_delta_rpm_config_value).and_return(nil) | ||
expect(ZyppConfig.new.use_delta_rpm?).to eq(true) | ||
end | ||
|
||
it "provides config value for delta rpms if explicitly deactivated" do | ||
ZyppConfig.any_instance.stub(:get_delta_rpm_config_value).and_return('false') | ||
expect(ZyppConfig.new.use_delta_rpm?).to eq(false) | ||
end | ||
|
||
it "can activate and deactivate use of delta rpms in zypp config" do | ||
ZyppConfig.any_instance.stub(:get_delta_rpm_config_value) | ||
ZyppConfig.any_instance.stub(:set_delta_rpm_config_value) | ||
config = ZyppConfig.new | ||
expect(config).to receive(:set_delta_rpm_config_value).with(true) | ||
expect(config.activate_delta_rpm) | ||
|
||
expect(config).to receive(:set_delta_rpm_config_value).with(false) | ||
expect(config.deactivate_delta_rpm) | ||
end | ||
end |