diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-26 14:51:21 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-03-15 18:03:29 -0700 |
commit | 1b38da9eba33b0c6e6628022c9343cca5037abd4 (patch) | |
tree | f3c02603a86261b9a8f45ed1ae0e98e8914006b1 /spec/unit | |
parent | c231f3d74fd8ebad0d2759b60fd45f4116a2402c (diff) | |
download | chef-1b38da9eba33b0c6e6628022c9343cca5037abd4.tar.gz |
fix yum_cache arch options and use positional parameters
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/package/yum/yum_cache_spec.rb | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/spec/unit/provider/package/yum/yum_cache_spec.rb b/spec/unit/provider/package/yum/yum_cache_spec.rb index ba78987de7..6b2a617ac8 100644 --- a/spec/unit/provider/package/yum/yum_cache_spec.rb +++ b/spec/unit/provider/package/yum/yum_cache_spec.rb @@ -31,32 +31,32 @@ describe Chef::Provider::Package::Yum::YumCache do end it "package_available? returns false if the helper reports the available version is nil" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo").and_return( yum_version("foo", nil, nil) ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: nil).and_return( yum_version("foo", nil, nil) ) expect( yum_cache.package_available?("foo") ).to be false end it "package_available? returns true if the helper returns an available version" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: nil).and_return( yum_version("foo", "1.2.3-1", "x86_64") ) expect( yum_cache.package_available?("foo") ).to be true end it "version_available? returns false if the helper reports the available version is nil" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", "1.2.3", nil).and_return( yum_version("foo", nil, nil) ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", version: "1.2.3", arch: nil).and_return( yum_version("foo", nil, nil) ) expect( yum_cache.version_available?("foo", "1.2.3") ).to be false end it "version_available? returns true if the helper returns an available version" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", "1.2.3", nil).and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", version: "1.2.3", arch: nil).and_return( yum_version("foo", "1.2.3-1", "x86_64") ) expect( yum_cache.version_available?("foo", "1.2.3") ).to be true end it "version_available? with an arch returns false if the helper reports the available version is nil" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", "1.2.3", "x86_64").and_return( yum_version("foo", nil, nil) ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", version: "1.2.3", arch: "x86_64").and_return( yum_version("foo", nil, nil) ) expect( yum_cache.version_available?("foo", "1.2.3", "x86_64") ).to be false end it "version_available? with an arch returns true if the helper returns an available version" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", "1.2.3", "x86_64").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", version: "1.2.3", arch: "x86_64").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) expect( yum_cache.version_available?("foo", "1.2.3", "x86_64") ).to be true end @@ -68,22 +68,42 @@ describe Chef::Provider::Package::Yum::YumCache do end it "installed_version? returns nil if the helper reports the installed version is nil" do - expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo").and_return( yum_version("foo", nil, nil) ) + expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo", arch: nil).and_return( yum_version("foo", nil, nil) ) expect( yum_cache.installed_version("foo") ).to be nil end it "installed_version? returns version string if the helper returns an installed version" do - expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo", arch: nil).and_return( yum_version("foo", "1.2.3-1", "x86_64") ) expect( yum_cache.installed_version("foo") ).to eql("1.2.3-1.x86_64") end + it "installed_version? returns nil if the helper reports the installed version is nil" do + expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo", arch: "x86_64").and_return( yum_version("foo", nil, nil) ) + expect( yum_cache.installed_version("foo", "x86_64") ).to be nil + end + + it "installed_version? returns version string if the helper returns an installed version" do + expect( python_helper ).to receive(:package_query).with(:whatinstalled, "foo", arch: "x86_64").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( yum_cache.installed_version("foo", "x86_64") ).to eql("1.2.3-1.x86_64") + end + it "available_version? returns nil if the helper reports the available version is nil" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo").and_return( yum_version("foo", nil, nil) ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: nil).and_return( yum_version("foo", nil, nil) ) expect( yum_cache.available_version("foo") ).to be nil end it "available_version? returns version string if the helper returns an available version" do - expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: nil).and_return( yum_version("foo", "1.2.3-1", "x86_64") ) expect( yum_cache.available_version("foo") ).to eql("1.2.3-1.x86_64") end + + it "available_version? returns nil if the helper reports the available version is nil" do + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: "x86_64").and_return( yum_version("foo", nil, nil) ) + expect( yum_cache.available_version("foo", "x86_64") ).to be nil + end + + it "available_version? returns version string if the helper returns an available version" do + expect( python_helper ).to receive(:package_query).with(:whatavailable, "foo", arch: "x86_64").and_return( yum_version("foo", "1.2.3-1", "x86_64") ) + expect( yum_cache.available_version("foo", "x86_64") ).to eql("1.2.3-1.x86_64") + end end |