summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorc5227532 <eike.waldt@sap.com>2016-09-28 19:49:49 +0200
committerc5227532 <eike.waldt@sap.com>2016-09-28 19:49:49 +0200
commit5320cb1b139defb1a37df0a12e26fe8dad1cc8bf (patch)
tree4f70ebd4403f3613a4d8e7e856eaf529a7e097bb /spec
parent7ed29654c4adf43efbdddd2dccc5afb014c88cca (diff)
downloadchef-5320cb1b139defb1a37df0a12e26fe8dad1cc8bf.tar.gz
implement locking
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/package/zypper_spec.rb18
-rw-r--r--spec/unit/provider/package_spec.rb37
2 files changed, 55 insertions, 0 deletions
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 8838c26b71..c64b113649 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -231,6 +231,24 @@ describe Chef::Provider::Package::Zypper do
end
end
+ describe "lock_package" do
+ it "should run zypper addlock with the package name" do
+ shell_out_expectation!(
+ "zypper addlock emacs"
+ )
+ provider.lock_package(["emacs"])
+ end
+ end
+
+ describe "unlock_package" do
+ it "should run zypper removelock with the package name" do
+ shell_out_expectation!(
+ "zypper removelock emacs"
+ )
+ provider.unlock_package(["emacs"])
+ end
+ end
+
describe "on an older zypper" do
before(:each) do
allow(provider).to receive(:`).and_return("0.11.6")
diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb
index 40b7516b5c..082fc00ba5 100644
--- a/spec/unit/provider/package_spec.rb
+++ b/spec/unit/provider/package_spec.rb
@@ -321,6 +321,35 @@ describe Chef::Provider::Package do
end
end
+ describe "When locking the package" do
+ before(:each) do
+ allow(provider).to receive(:lock_package).and_return(true)
+ end
+
+ it "should lock the package if it is unlocked" do
+ expect(provider).to be_locking_package
+ expect(provider).to receive(:lock_package).with("emacs")
+ provider.run_action(:lock)
+ expect(new_resource).to be_updated
+ expect(new_resource).to be_updated_by_last_action
+ end
+
+ it "should not purge the package if it is not installed" do
+ current_resource.instance_variable_set(:@version, nil)
+ expect(provider).not_to be_locking_package
+
+ expect(provider).not_to receive(:lock_package)
+ provider.run_action(:lock)
+ expect(new_resource).not_to be_updated_by_last_action
+ end
+
+ it "should set the resource to updated if it purges the package" do
+ provider.run_action(:lock)
+ expect(new_resource).to be_updated
+ end
+
+ end
+
describe "when running commands to be implemented by subclasses" do
it "should raises UnsupportedAction for install" do
expect { provider.install_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
@@ -346,6 +375,14 @@ describe Chef::Provider::Package do
it "should raise UnsupportedAction for reconfig" do
expect { provider.reconfig_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
+
+ it "should raise UnsupportedAction for lock" do
+ expect { provider.lock_package("emacs") }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ end
+
+ it "should raise UnsupportedAction for unlock" do
+ expect { provider.unlock_package("emacs") }.to raise_error(Chef::Exceptions::UnsupportedAction)
+ end
end
describe "when given a response file" do