summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorpratixha <pratiksha.prajapati@msystechnologies.com>2022-05-10 17:56:00 +0530
committerpratixha <pratiksha.prajapati@msystechnologies.com>2022-05-25 12:13:25 +0530
commitfa552fab9be9551dbc8f06f98c35a28b21fe7d82 (patch)
tree625444b40f9ffe88313295443e9e2f1c1617d2a1 /spec
parent9e40fb06c3659a8f3c2d53b0fa476fcc6775f66b (diff)
downloadchef-fa552fab9be9551dbc8f06f98c35a28b21fe7d82.tar.gz
Missing source path unit and functional specs
Signed-off-by: pratixha <pratiksha.prajapati@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/zypper_package_spec.rb5
-rw-r--r--spec/unit/provider/package/zypper_spec.rb13
2 files changed, 17 insertions, 1 deletions
diff --git a/spec/functional/resource/zypper_package_spec.rb b/spec/functional/resource/zypper_package_spec.rb
index 87c5f0e5e3..fbf394bae8 100644
--- a/spec/functional/resource/zypper_package_spec.rb
+++ b/spec/functional/resource/zypper_package_spec.rb
@@ -81,6 +81,11 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
end
+ it "raises an error when passed a source that does not exist" do
+ zypper_package.source = "#{CHEF_SPEC_ASSETS}/false/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
+ expect { zypper_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
+ end
+
it "does not install if the package is installed" do
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
zypper_package.run_action(:install)
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 95810edcb4..2850a70560 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -174,6 +174,12 @@ describe Chef::Provider::Package::Zypper do
)
provider.install_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
end
+
+ it "should raise an exception if a source is supplied but not found when :install" do
+ new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
+ expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
+ end
end
describe "upgrade_package" do
@@ -218,9 +224,14 @@ describe Chef::Provider::Package::Zypper do
shell_out_expectation!(
"zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
)
- provider.install_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
+ provider.upgrade_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
end
+ it "should raise an exception if a source is supplied but not found when :upgrade" do
+ new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
+ allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
+ expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
+ end
end
describe "remove_package" do