diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package/yum_spec.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 0d2a44f3ae..160deb964b 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -50,23 +50,23 @@ describe Chef::Provider::Package::Yum do it "should set the current resources package name to the new resources package name" do @provider.load_current_resource - expect(@provider.current_resource.package_name).to eq("cups") + expect(@provider.current_resource.package_name).to eq(["cups"]) end it "should set the installed version to nil on the current resource if no installed package" do - allow(@yum_cache).to receive(:installed_version).and_return(nil) + allow(@yum_cache).to receive(:installed_version).and_return([nil]) @provider.load_current_resource - expect(@provider.current_resource.version).to be_nil + expect(@provider.current_resource.version).to eq([nil]) end it "should set the installed version if yum has one" do @provider.load_current_resource - expect(@provider.current_resource.version).to eq("1.2.4-11.18.el5") + expect(@provider.current_resource.version).to eq(["1.2.4-11.18.el5"]) end it "should set the candidate version if yum info has one" do @provider.load_current_resource - expect(@provider.candidate_version).to eql("1.2.4-11.18.el5_2.3") + expect(@provider.candidate_version).to eql(["1.2.4-11.18.el5_2.3"]) end it "should return the current resouce" do @@ -96,14 +96,14 @@ describe Chef::Provider::Package::Yum do allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing") + expect(@provider.new_resource.package_name).to eq(["testing"]) expect(@provider.new_resource.arch).to eq("noarch") expect(@provider.arch).to eq("noarch") @new_resource = Chef::Resource::YumPackage.new('testing.more.noarch') @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.more") + expect(@provider.new_resource.package_name).to eq(["testing.more"]) expect(@provider.new_resource.arch).to eq("noarch") expect(@provider.arch).to eq("noarch") end @@ -131,14 +131,14 @@ describe Chef::Provider::Package::Yum do @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) # annoying side effect of the fun stub'ing above @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.beta3") + expect(@provider.new_resource.package_name).to eq(["testing.beta3"]) expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.beta3.more") + expect(@provider.new_resource.package_name).to eq(["testing.beta3.more"]) expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) end @@ -161,14 +161,14 @@ describe Chef::Provider::Package::Yum do allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.beta3") + expect(@provider.new_resource.package_name).to eq(["testing.beta3"]) expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.beta3.more") + expect(@provider.new_resource.package_name).to eq(["testing.beta3.more"]) expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) end @@ -196,7 +196,7 @@ describe Chef::Provider::Package::Yum do allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@provider.new_resource.package_name).to eq("testing.i386") + expect(@provider.new_resource.package_name).to eq(["testing.i386"]) expect(@provider.new_resource.arch).to eq("x86_64") end end @@ -247,7 +247,7 @@ describe Chef::Provider::Package::Yum do expect(@yum_cache).to receive(:packages_from_require).and_return([pkg]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.package_name).to eq(["test-package"]) end it "should search provides if package name can't be found, warn about multiple matches, but use the first one" do @@ -268,7 +268,7 @@ describe Chef::Provider::Package::Yum do expect(Chef::Log).to receive(:warn).exactly(1).times.with(%r{matched multiple Provides}) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq("test-package-x") + expect(@new_resource.package_name).to eq(["test-package-x"]) end it "should search provides if no package is available - if no match in installed provides then load the complete set" do @@ -328,7 +328,7 @@ describe Chef::Provider::Package::Yum do expect(@yum_cache).to receive(:packages_from_require).twice.and_return([]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq("cups") + expect(@new_resource.package_name).to eq(["cups"]) end end @@ -337,9 +337,9 @@ describe Chef::Provider::Package::Yum do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( - "yum -d0 -e0 -y install emacs-1.0" + "yum -d0 -e0 -y install cups-1.2.4-11.19.el5" ) - @provider.install_package("emacs", "1.0") + @provider.install_package(["cups"], ["1.2.4-11.19.el5"]) end it "should run yum localinstall if given a path to an rpm" do @@ -347,7 +347,7 @@ describe Chef::Provider::Package::Yum do expect(@provider).to receive(:yum_command).with( "yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm" ) - @provider.install_package("emacs", "21.4-20.el5") + @provider.install_package(["emacs"], ["21.4-20.el5"]) end it "should run yum localinstall if given a path to an rpm as the package" do @@ -358,7 +358,7 @@ describe Chef::Provider::Package::Yum do expect(@provider).to receive(:yum_command).with( "yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm" ) - @provider.install_package("/tmp/emacs-21.4-20.el5.i386.rpm", "21.4-20.el5") + @provider.install_package(["/tmp/emacs-21.4-20.el5.i386.rpm"], ["21.4-20.el5"]) end it "should run yum install with the package name, version and arch" do @@ -366,14 +366,14 @@ describe Chef::Provider::Package::Yum do allow(@new_resource).to receive(:arch).and_return("i386") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( - "yum -d0 -e0 -y install emacs-21.4-20.el5.i386" + "yum -d0 -e0 -y install cups-1.2.4-11.19.el5.i386" ) - @provider.install_package("emacs", "21.4-20.el5") + @provider.install_package(["cups"], ["1.2.4-11.19.el5"]) end it "installs the package with the options given in the resource" do @provider.load_current_resource - @provider.candidate_version = '11' + @provider.candidate_version = ['11'] allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( @@ -467,10 +467,10 @@ describe Chef::Provider::Package::Yum do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( - "yum -d0 -e0 -y install emacs-1.0" + "yum -d0 -e0 -y install cups-1.2.4-11.15.el5" ) expect(@yum_cache).to receive(:reload).once - @provider.install_package("emacs", "1.0") + @provider.install_package("cups", "1.2.4-11.15.el5") end it "should run yum install then not flush the cache if :after is false" do @@ -478,10 +478,10 @@ describe Chef::Provider::Package::Yum do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( - "yum -d0 -e0 -y install emacs-1.0" + "yum -d0 -e0 -y install cups-1.2.4-11.15.el5" ) expect(@yum_cache).not_to receive(:reload) - @provider.install_package("emacs", "1.0") + @provider.install_package("cups", "1.2.4-11.15.el5") end end @@ -530,10 +530,10 @@ describe Chef::Provider::Package::Yum do allow(@yum_cache).to receive(:installed_version).and_return(nil) @provider.load_current_resource @current_resource = Chef::Resource::Package.new('cups') - @provider.candidate_version = '11' + @provider.candidate_version = ['11'] expect(@provider).to receive(:upgrade_package).with( - "cups", - "11" + ["cups"], + ["11"] ) @provider.action_upgrade end @@ -541,7 +541,7 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate version is nil" do @provider.load_current_resource @current_resource = Chef::Resource::Package.new('cups') - @provider.candidate_version = nil + @provider.candidate_version = [nil] expect(@provider).not_to receive(:upgrade_package) @provider.action_upgrade end @@ -549,10 +549,10 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate is newer" do @provider.load_current_resource @current_resource = Chef::Resource::Package.new('cups') - @provider.candidate_version = '11' + @provider.candidate_version = ['11'] expect(@provider).to receive(:upgrade_package).with( - "cups", - "11" + ["cups"], + ["11"] ) @provider.action_upgrade end @@ -561,7 +561,7 @@ describe Chef::Provider::Package::Yum do allow(@yum_cache).to receive(:installed_version).and_return("12") @provider.load_current_resource @current_resource = Chef::Resource::Package.new('cups') - @provider.candidate_version = '11' + @provider.candidate_version = ['11'] expect(@provider).not_to receive(:upgrade_package) @provider.action_upgrade end |