summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManick Vel <mkumaravel@msystechnologies.com>2022-01-20 18:03:38 +0530
committerpratixha <pratiksha.prajapati@msystechnologies.com>2022-05-25 12:13:22 +0530
commit394e75398a84b5bf13b835bc46ed598384eb7bd0 (patch)
tree834a13832ee269bf5c2d4c516066d97682cfac2e
parent2d2f03241fa9682ba7899c027ab10d3888cbcedd (diff)
downloadchef-394e75398a84b5bf13b835bc46ed598384eb7bd0.tar.gz
Addressed source_file_exist and uri_scheme related changes
Signed-off-by: Manick Vel <mkumaravel@msystechnologies.com>
-rw-r--r--lib/chef/provider/package/zypper.rb14
-rw-r--r--spec/unit/provider/package/zypper_spec.rb14
2 files changed, 7 insertions, 21 deletions
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index 3b674ea7ce..0f268c2cee 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