diff options
author | Lance Albertson <lance@osuosl.org> | 2023-04-18 12:21:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 15:21:47 -0400 |
commit | 6fdfe6ba975bd03da6b03225d7fe19f10b0f7306 (patch) | |
tree | 581cab969a90b4bf572bf68d65dcc26ff1b5e3cb /spec | |
parent | 09403f49de67b31fb1d6a8fbd4767dd0b22b9dee (diff) | |
download | chef-6fdfe6ba975bd03da6b03225d7fe19f10b0f7306.tar.gz |
zypper_package: Fix idempotency issue (#13691)
Installing the apache2-mod_wsgi-python3 package is not idempotent due to the
fact that zypper will also return the apache2-mod_wsgi package. The
resolve_available_version method, incorrectly assumes this will only return one
item, but in this case it returns four items and will pick the first package
listed.
To work around this, we should verify that the package name listed in the output
matches what we are expecting to install.
Signed-off-by: Lance Albertson <lance@osuosl.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package/zypper_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 2850a70560..c26443a148 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -491,4 +491,14 @@ describe Chef::Provider::Package::Zypper do provider.remove_package(%w{emacs vim}, ["1.0", "2.0"]) end end + + describe "resolve_available_version" do + it "should return correct version if multiple packages are shown" do + status = double(stdout: "S | Name | Type | Version | Arch | Repository\n---+--------------------------+---------+---------------------+--------+-------------------------------------------------------------\n | apache2-mod_wsgi | package | 4.7.1-150400.3.3.1 | x86_64 | Update repository with updates from SUSE Linux Enterprise 15\n | apache2-mod_wsgi | package | 4.7.1-150400.1.52 | x86_64 | Main Repository\ni+ | apache2-mod_wsgi-python3 | package | 4.5.18-150000.4.6.1 | x86_64 | Update repository with updates from SUSE Linux Enterprise 15\nv | apache2-mod_wsgi-python3 | package | 4.5.18-4.3.1 | x86_64 | Main Repository\n", exitstatus: 0) + + allow(provider).to receive(:shell_out_compacted!).and_return(status) + result = provider.send(:resolve_available_version, "apache2-mod_wsgi-python3", nil) + expect(result).to eq("4.5.18-150000.4.6.1") + end + end end |