summaryrefslogtreecommitdiff
path: root/spec/unit/provider/package/zypper_spec.rb
diff options
context:
space:
mode:
authorIonuț Arțăriși <iartarisi@suse.cz>2013-02-25 18:10:19 +0100
committerBryan McLellan <btm@opscode.com>2013-05-24 10:20:20 -0700
commit1e2dd728f8d9ad724aa2980d5fb15c2e26d6bed8 (patch)
tree3079a16841d0ecc7ef9046ba5a61494ef8a778be /spec/unit/provider/package/zypper_spec.rb
parent7e9c4cdfbfb45fc8e5bab773ad7efc94bbc58961 (diff)
downloadchef-1e2dd728f8d9ad724aa2980d5fb15c2e26d6bed8.tar.gz
CHEf-4090: refactor zypper commands and use shell_out
Diffstat (limited to 'spec/unit/provider/package/zypper_spec.rb')
-rw-r--r--spec/unit/provider/package/zypper_spec.rb89
1 files changed, 44 insertions, 45 deletions
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index c0b2fe4658..9cd77375db 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -93,24 +93,23 @@ describe Chef::Provider::Package::Zypper do
describe "install_package" do
it "should run zypper install with the package name and version" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive install --auto-agree-with-licenses emacs=1.0")
@provider.install_package("emacs", "1.0")
end
it "should run zypper install without gpg checks" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks install "+
+ "--auto-agree-with-licenses emacs=1.0")
@provider.install_package("emacs", "1.0")
end
it "should warn about gpg checks on zypper install" do
Chef::Log.should_receive(:warn).with(
/All packages will be installed without gpg signature checks/)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks install "+
+ "--auto-agree-with-licenses emacs=1.0")
@provider.install_package("emacs", "1.0")
end
end
@@ -118,24 +117,30 @@ describe Chef::Provider::Package::Zypper do
describe "upgrade_package" do
it "should run zypper update with the package name and version" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive install --auto-agree-with-licenses emacs=1.0")
@provider.upgrade_package("emacs", "1.0")
end
it "should run zypper update without gpg checks" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks install "+
+ "--auto-agree-with-licenses emacs=1.0")
@provider.upgrade_package("emacs", "1.0")
end
it "should warn about gpg checks on zypper upgrade" do
Chef::Log.should_receive(:warn).with(
/All packages will be installed without gpg signature checks/)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks install -l emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks install "+
+ "--auto-agree-with-licenses emacs=1.0")
+ @provider.upgrade_package("emacs", "1.0")
+ end
+ it "should run zypper upgrade without gpg checks" do
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks install "+
+ "--auto-agree-with-licenses emacs=1.0")
+
@provider.upgrade_package("emacs", "1.0")
end
end
@@ -143,46 +148,43 @@ describe Chef::Provider::Package::Zypper do
describe "remove_package" do
it "should run zypper remove with the package name" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(true)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n remove emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive remove emacs=1.0")
@provider.remove_package("emacs", "1.0")
end
it "should run zypper remove without gpg checks" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks remove emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks remove emacs=1.0")
@provider.remove_package("emacs", "1.0")
end
it "should warn about gpg checks on zypper remove" do
Chef::Log.should_receive(:warn).with(
/All packages will be installed without gpg signature checks/)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks remove emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks remove emacs=1.0")
+
@provider.remove_package("emacs", "1.0")
end
end
describe "purge_package" do
it "should run remove_package with the name and version" do
- @provider.should_receive(:remove_package).with("emacs", "1.0")
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0")
@provider.purge_package("emacs", "1.0")
end
it "should run zypper purge without gpg checks" do
Chef::Config.stub(:[]).with(:zypper_check_gpg).and_return(false)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks remove emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0")
@provider.purge_package("emacs", "1.0")
end
it "should warn about gpg checks on zypper purge" do
Chef::Log.should_receive(:warn).with(
/All packages will be installed without gpg signature checks/)
- @provider.should_receive(:run_command).with({
- :command => "zypper -n --no-gpg-checks remove emacs=1.0",
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --non-interactive --no-gpg-checks remove --clean-deps emacs=1.0")
@provider.purge_package("emacs", "1.0")
end
end
@@ -194,27 +196,24 @@ describe Chef::Provider::Package::Zypper do
describe "install_package" do
it "should run zypper install with the package name and version" do
- @provider.should_receive(:run_command).with({
- :command => "zypper install -y emacs"
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs")
@provider.install_package("emacs", "1.0")
end
end
-
+
describe "upgrade_package" do
it "should run zypper update with the package name and version" do
- @provider.should_receive(:run_command).with({
- :command => "zypper install -y emacs"
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --no-gpg-checks install --auto-agree-with-licenses -y emacs")
@provider.upgrade_package("emacs", "1.0")
end
end
-
+
describe "remove_package" do
it "should run zypper remove with the package name" do
- @provider.should_receive(:run_command).with({
- :command => "zypper remove -y emacs"
- })
+ @provider.should_receive(:shell_out!).with(
+ "zypper --no-gpg-checks remove -y emacs")
@provider.remove_package("emacs", "1.0")
end
end