diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-07-07 18:01:59 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-07-07 18:35:05 -0700 |
commit | 8a44ff88660219317cc3bdefe4c2e021660bdee4 (patch) | |
tree | 995f42e2695be2542ff78ebd83982ba1a8616c59 /spec/unit | |
parent | 8dfb972e9dd8c760b453d76b5db73f1f8b96ecb0 (diff) | |
download | chef-8a44ff88660219317cc3bdefe4c2e021660bdee4.tar.gz |
Update tests to match how Windows package checksums are done.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/package/windows_spec.rb | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index c327e4217b..c52012b938 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -414,51 +414,23 @@ describe Chef::Provider::Package::Windows, :windows_only do Chef::Config[:why_run] = false end end - end - - shared_context "valid checksum" do - context "checksum is valid" do - before do - allow(provider).to receive(:checksum).and_return("jiie00u3bbs92vsbhvgvklb2lasgh20ah") - end - - it "does not raise the checksum mismatch exception" do - expect { provider.send(:validate_content!) }.to_not raise_error - end - end - end - shared_context "invalid checksum" do - context "checksum is invalid" do - before do - allow(provider).to receive(:checksum).and_return("kiie30u3bbs92vsbhvgvklb2lasgh20ah") - end + it "does not raise an error with a valid checksum" do + expect(Chef::Digester).to receive(:checksum_for_file).with(new_resource.source).and_return("abcdef1234567890") + expect(provider).to receive(:install_package) - it "raises the checksum mismatch exception" do - expect { provider.send(:validate_content!) }.to raise_error( - Chef::Exceptions::ChecksumMismatch - ) - end - end - end + new_resource.checksum("abcdef1234567890") - describe "validate_content!" do - before(:each) do - new_resource.checksum("jiie00u3bbs92vsbhvgvklb2lasgh20ah") + provider.run_action(:install) end - context "checksum is in lowercase" do - include_context "valid checksum" - include_context "invalid checksum" - end + it "raises an error with an invalid checksum" do + expect(Chef::Digester).to receive(:checksum_for_file).with(new_resource.source).and_return("abcdef1234567890") + expect(provider).not_to receive(:install_package) - context "checksum is in uppercase" do - before do - new_resource.checksum = new_resource.checksum.upcase - end + new_resource.checksum("ffffffffffffffff") - include_context "valid checksum" - include_context "invalid checksum" + expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end end end |