From f694f09734a6752c809626fe9af53b8c29c9b898 Mon Sep 17 00:00:00 2001 From: Yorgos Saslis Date: Sat, 24 Oct 2015 03:29:29 +0300 Subject: [PATCH] Added support for Zypper to install multiple packages at once See #3570 --- spec/unit/provider/package/zypper_spec.rb | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 69038bf5526..28a6fe8e85b 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -252,4 +252,40 @@ def shell_out_expectation!(command, options=nil) end end end + + describe "when installing multiple packages" do # https://github.com/chef/chef/issues/3570 + it "should install an array of package names and versions" do + allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) + shell_out_expectation!( + "zypper --non-interactive --no-gpg-checks install "+ + "--auto-agree-with-licenses emacs=1.0 vim=2.0" + ) + provider.install_package(["emacs", "vim"], ["1.0", "2.0"]) + end + + it "should install an array of package names without versions" do + allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) + shell_out_expectation!( + "zypper --non-interactive --no-gpg-checks install "+ + "--auto-agree-with-licenses emacs vim" + ) + provider.install_package(["emacs", "vim"], nil) + end + + it "should remove an array of package names and versions" do + allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) + shell_out_expectation!( + "zypper --non-interactive --no-gpg-checks remove emacs=1.0 vim=2.0" + ) + provider.remove_package(["emacs", "vim"], ["1.0", "2.0"]) + end + + it "should remove an array of package names without versions" do + allow(Chef::Config).to receive(:[]).with(:zypper_check_gpg).and_return(false) + shell_out_expectation!( + "zypper --non-interactive --no-gpg-checks remove emacs vim" + ) + provider.remove_package(["emacs", "vim"], nil) + end + end end