summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnehaldwivedi <sdwivedi@msystechnologies.com>2020-07-10 15:17:00 +0530
committerSnehal Dwivedi <snehal.dwivedi@AD.MSYSTECHNOLOGIES.COM>2020-07-14 10:34:44 +0530
commit00c010595183c38283ebb16c7d49c774bd5050b5 (patch)
tree561350b319490b30766c1113abc2341e86fe07f3
parent11f448cb268731a83fab43f034d1ee313e3edf31 (diff)
downloadchef-snehal/Fix_the_Windows_unit_tests.tar.gz
Updated reviewed changessnehal/Fix_the_Windows_unit_tests
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
-rw-r--r--lib/chef/mixin/openssl_helper.rb1
-rw-r--r--spec/support/shared/unit/provider/file.rb2
-rw-r--r--spec/unit/data_bag_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb11
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb2
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb52
6 files changed, 31 insertions, 39 deletions
diff --git a/lib/chef/mixin/openssl_helper.rb b/lib/chef/mixin/openssl_helper.rb
index e7f09c0551..3cb20a4569 100644
--- a/lib/chef/mixin/openssl_helper.rb
+++ b/lib/chef/mixin/openssl_helper.rb
@@ -245,6 +245,7 @@ class Chef
def gen_serial
::OpenSSL::BN.generate_prime(160)
end
+
# generate a Certificate given a X509 request
# @param [OpenSSL::X509::Request] request X509 Certificate Request
# @param [Array] extension Array of X509 Certificate Extension
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 6a67be4a24..f624a6ae44 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -503,7 +503,7 @@ shared_examples_for Chef::Provider::File do
expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, /sensitive/)
end
end
- end
+ end
context "do_create_file" do
context "when the file exists" do
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 397429f177..2a7ddddd5b 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -237,7 +237,7 @@ describe Chef::DataBag do
data_bag_list = Chef::DataBag.list
expect(data_bag_list).to eq({ "bar" => "bar", "foo" => "foo" })
end
-
+
it "should raise an error if the configured data_bag_path is invalid" do
file_dir_stub(@paths.first, false)
msg = "Data bag path '#{windows? ? "C:/var/chef" : "/var/chef"}/data_bags' not found. Please create this directory."
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index 5ec001076b..bc13ce834c 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -323,27 +323,16 @@ describe Chef::Knife::CookbookUpload do
context "when cookbook path is an array" do
it "should warn users that no cookbooks exist" do
-<<<<<<< HEAD
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.")
-=======
- coockbook_path = windows? ? "C:/chef-repo/cookbooks" : "C:/chef-repo/cookbooks"
- knife.config[:cookbook_path] = [coockbook_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."
- )
->>>>>>> 49dd031b3... Fixed windows unit tests
knife.run
end
end
context "when cookbook path is a string" do
it "should warn users that no cookbooks exist" do
-<<<<<<< HEAD
knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
-=======
- knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "C:/chef-repo/cookbooks"
->>>>>>> 49dd031b3... Fixed windows unit tests
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."
)
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index b5493293a6..9a1bee5689 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -187,7 +187,7 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
describe "#start_chef" do
it "returns the expected string" do
- expect(bootstrap_context.start_chef).to match(%r{SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\;%PATH%\"\n})
+ expect(bootstrap_context.start_chef).to match(%r{SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\/opscode\/chef\\bin;C:\/opscode\/chef\\embedded\\bin\;%PATH%\"\n})
end
end
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 6298fa34ab..e1170b4fc5 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-describe Chef::Provider::SystemdUnit, :linux_only do
+describe Chef::Provider::SystemdUnit do
let(:node) { Chef::Node.new }
let(:events) { Chef::EventDispatch::Dispatcher.new }
@@ -222,31 +222,33 @@ describe Chef::Provider::SystemdUnit, :linux_only do
# A password is required when specifying a user on Windows. Since systemd resources
# won't actually run on Windows, skip these tests rather than code a workaround.
- it "loads the user unit content if the file exists and user is set" do
- new_resource.user("joe")
- allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(true)
- allow(File).to receive(:read)
- .with(unit_path_user)
- .and_return(unit_content_string)
- expect(File).to receive(:exist?)
- .with(unit_path_user)
- expect(File).to receive(:read)
- .with(unit_path_user)
- provider.load_current_resource
- expect(current_resource.content).to eq(unit_content_string)
- end
+ unless windows?
+ it "loads the user unit content if the file exists and user is set" do
+ new_resource.user("joe")
+ allow(File).to receive(:exist?)
+ .with(unit_path_user)
+ .and_return(true)
+ allow(File).to receive(:read)
+ .with(unit_path_user)
+ .and_return(unit_content_string)
+ expect(File).to receive(:exist?)
+ .with(unit_path_user)
+ expect(File).to receive(:read)
+ .with(unit_path_user)
+ provider.load_current_resource
+ expect(current_resource.content).to eq(unit_content_string)
+ end
- it "does not load the user unit if the file does not exist and user is set" do
- new_resource.user("joe")
- allow(File).to receive(:exist?)
- .with(unit_path_user)
- .and_return(false)
- expect(File).to_not receive(:read)
- .with(unit_path_user)
- provider.load_current_resource
- expect(current_resource.content).to eq(nil)
+ it "does not load the user unit if the file does not exist and user is set" do
+ new_resource.user("joe")
+ allow(File).to receive(:exist?)
+ .with(unit_path_user)
+ .and_return(false)
+ expect(File).to_not receive(:read)
+ .with(unit_path_user)
+ provider.load_current_resource
+ expect(current_resource.content).to eq(nil)
+ end
end
end