summaryrefslogtreecommitdiff
path: root/spec/unit/provider/systemd_unit_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/systemd_unit_spec.rb')
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb61
1 files changed, 37 insertions, 24 deletions
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index cf26c99b77..b13ca9448b 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -220,31 +220,44 @@ 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
+ if windows?
+ it "fails when attempting to set the user on Windows" 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)
+
+ expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::InvalidCommandOption)
+ end
+ else
+ 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