diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-08 11:05:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 11:05:43 -0700 |
commit | 51b02ad621755a884f782b3819fec69b220b0c6f (patch) | |
tree | 43758991e3ac89344a03949ec2efff1081e80ead | |
parent | 73e51dd1411c9fe2c1018c3e4eb6961e85b23357 (diff) | |
parent | ff6afe131637c8bdff85663460ebbb3949756f15 (diff) | |
download | chef-51b02ad621755a884f782b3819fec69b220b0c6f.tar.gz |
Merge pull request #10127 from chef/fix-systemd-unit-test-on-windows
Fix systemd unit test on Windows.
-rw-r--r-- | spec/unit/provider/systemd_unit_spec.rb | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb index cf26c99b77..e1170b4fc5 100644 --- a/spec/unit/provider/systemd_unit_spec.rb +++ b/spec/unit/provider/systemd_unit_spec.rb @@ -220,31 +220,35 @@ describe Chef::Provider::SystemdUnit do expect(current_resource.content).to eq(nil) end - 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 + # 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. + 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 |