diff options
author | Manick Vel <mkumaravel@msystechnologies.com> | 2022-01-20 18:03:38 +0530 |
---|---|---|
committer | Manick Vel <mkumaravel@msystechnologies.com> | 2022-01-20 18:03:38 +0530 |
commit | b330c737c9c638c3470c0005985737816fa5d45e (patch) | |
tree | 779f4486944663fff199991cf44ae8efa4111275 | |
parent | a52b80bdd6c897ef2f008677835d598a0ad72af0 (diff) | |
download | chef-manick/11638_zypper_package_source_addition.tar.gz |
Addressed source_file_exist and uri_scheme related changesmanick/11638_zypper_package_source_addition
Signed-off-by: Manick Vel <mkumaravel@msystechnologies.com>
-rw-r--r-- | lib/chef/provider/package/zypper.rb | 14 | ||||
-rw-r--r-- | spec/unit/provider/package/zypper_spec.rb | 14 |
2 files changed, 7 insertions, 21 deletions
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb index 99bb6b6664..39c5af9d24 100644 --- a/lib/chef/provider/package/zypper.rb +++ b/lib/chef/provider/package/zypper.rb @@ -72,11 +72,6 @@ class Chef def candidate_version if source_files_exist? - unless uri_scheme?(new_resource.source) || ::File.exist?(new_resource.source) - @package_source_exists = false - return - end - logger.trace("#{new_resource} checking rpm status") shell_out!("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", new_resource.source).stdout.each_line do |line| case line @@ -92,15 +87,6 @@ class Chef end end - def uri_scheme?(str) - scheme = URI.split(str).first - return false unless scheme - - %w{http https ftp file}.include?(scheme.downcase) - rescue URI::InvalidURIError - false - end - def resolve_current_version(package_name) latest_version = current_version = nil is_installed = false diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 024bb1b26d..bc28e42f1d 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -32,7 +32,7 @@ describe Chef::Provider::Package::Zypper do let(:status) { double(stdout: "\n", exitstatus: 0) } - let(:source) { "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" } + let(:source) { "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" } before(:each) do allow(Chef::Resource::Package).to receive(:new).and_return(current_resource) @@ -167,10 +167,10 @@ describe Chef::Provider::Package::Zypper do end it "should run zypper install with source option" do - new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" - allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.deb").and_return(true) + new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" + allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true) shell_out_expectation!( - "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" + "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" ) provider.install_package(["emacs"], ["1.0"]) end @@ -213,10 +213,10 @@ describe Chef::Provider::Package::Zypper do end it "should run zypper upgrade with source option" do - new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" - allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.deb").and_return(true) + new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" + allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true) shell_out_expectation!( - "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" + "zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" ) provider.upgrade_package(["emacs"], ["1.0"]) end |