diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-12 00:03:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-12 00:03:00 -0700 |
commit | 20d5cbf5a2dcdbf83f8a4d86ff3c2131f91b0c65 (patch) | |
tree | d4672ab1fc12f42a89ea8a9d7e27e00bbf046e27 | |
parent | 96cbb1f85ae5146e120e2e323d47dba3a4bce23f (diff) | |
parent | 37b00c232a7c79b3e47a8893b60df36baf86ff6e (diff) | |
download | chef-20d5cbf5a2dcdbf83f8a4d86ff3c2131f91b0c65.tar.gz |
Merge pull request #10144 from chef/fix-windows-unit-tests
Fix some windows unit tests
-rw-r--r-- | spec/unit/knife/cookbook_upload_spec.rb | 11 | ||||
-rw-r--r-- | spec/unit/provider/package/windows_spec.rb | 21 |
2 files changed, 18 insertions, 14 deletions
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb index 661eb779ea..bc13ce834c 100644 --- a/spec/unit/knife/cookbook_upload_spec.rb +++ b/spec/unit/knife/cookbook_upload_spec.rb @@ -323,19 +323,18 @@ describe Chef::Knife::CookbookUpload do context "when cookbook path is an array" do it "should warn users that no cookbooks exist" do - knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"] - expect(knife.ui).to receive(:warn).with( - /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(', ')}'\. Use --cookbook-path to specify the desired path\./ - ) + cookbook_path = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks" + knife.config[:cookbook_path] = [cookbook_path, "/home/user/cookbooks"] + expect(knife.ui).to receive(:warn).with("Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(", ")}'. Use --cookbook-path to specify the desired path.") knife.run end end context "when cookbook path is a string" do it "should warn users that no cookbooks exist" do - knife.config[:cookbook_path] = "/chef-repo/cookbooks" + knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks" expect(knife.ui).to receive(:warn).with( - /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'\. Use --cookbook-path to specify the desired path\./ + "Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'. Use --cookbook-path to specify the desired path." ) knife.run end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index b9a32ffd66..6531d9c5ec 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -70,16 +70,18 @@ describe Chef::Provider::Package::Windows, :windows_only do end end - context "when the source is a uri" do - let(:resource_source) { "https://foo.bar/calculator.msi" } - - context "when the source has not been downloaded" do + context "when the source is not present it loads from cache" do + context "when the package is not installed" do before(:each) do - allow(provider).to receive(:downloadable_file_missing?).and_return(true) + allow(provider).to receive(:uri_scheme?).and_return(false) + allow(provider.package_provider).to receive(:get_product_property).and_return(nil) + allow(provider.package_provider).to receive(:get_installed_version).and_return(nil) + allow(provider.package_provider).to receive(:package_version).and_return(nil) end - it "sets the current version to unknown" do + + it "sets the current version nil" do provider.load_current_resource - expect(provider.current_resource.version).to eql("unknown") + expect(provider.current_resource.version).to eql(nil) end end @@ -312,7 +314,10 @@ describe Chef::Provider::Package::Windows, :windows_only do let(:resource_source) { "https://foo.bar/calculator.exe" } it "downloads the http resource" do - allow(File).to receive(:exist?).with('c:\cache\calculator.exe').and_return(false) + allow(provider).to receive(:uri_scheme?).and_return(true) + allow(provider).to receive(:installer_type).and_return(nil) + allow(File).to receive(:exist?).with("https\\foo.bar\\calculator.exe").and_return(false) + allow(provider).to receive(:compile_and_converge_action) expect(provider).to receive(:download_source_file) provider.run_action(:install) end |