summaryrefslogtreecommitdiff
path: root/spec/unit/provider/systemd_unit_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-07-06 12:23:53 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-07-06 12:36:15 -0700
commite2f21177cae1da7dc462a8f17a3f73e5c915cba0 (patch)
treec49e14b68003a54b812b786007bc31383fe03b3a /spec/unit/provider/systemd_unit_spec.rb
parentc35434e190f2fb5a48c94c577070af82d6ec0743 (diff)
downloadchef-e2f21177cae1da7dc462a8f17a3f73e5c915cba0.tar.gz
rebase + squash
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/provider/systemd_unit_spec.rb')
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb261
1 files changed, 130 insertions, 131 deletions
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index 93f624933f..00f39d0fd9 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -24,7 +24,6 @@ describe Chef::Provider::SystemdUnit do
let(:events) { Chef::EventDispatch::Dispatcher.new }
let(:run_context) { Chef::RunContext.new(node, {}, events) }
let(:unit_name) { "sysstat-collect\\x2d.timer" }
- let(:unit_name_escaped) { "sysstat-collect\\\\x2d.timer" }
let(:user_name) { "joe" }
let(:current_resource) { Chef::Resource::SystemdUnit.new(unit_name) }
let(:new_resource) { Chef::Resource::SystemdUnit.new(unit_name) }
@@ -285,9 +284,9 @@ describe Chef::Provider::SystemdUnit do
new_resource.user("joe")
allow(provider).to receive(:manage_unit_file).with(:create)
expect(new_resource.triggers_reload).to eq true
- allow(provider).to receive(:shell_out!)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_create
end
@@ -298,9 +297,9 @@ describe Chef::Provider::SystemdUnit do
.and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
expect(new_resource.triggers_reload).to eq true
- allow(provider).to receive(:shell_out!)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_delete
end
@@ -308,9 +307,9 @@ describe Chef::Provider::SystemdUnit do
new_resource.user("joe")
new_resource.triggers_reload(false)
allow(provider).to receive(:manage_unit_file).with(:create)
- allow(provider).to receive(:shell_out!)
- expect(provider).to_not receive(:shell_out!)
- .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to_not receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_create
end
@@ -321,9 +320,9 @@ describe Chef::Provider::SystemdUnit do
.with(unit_path_user)
.and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
- allow(provider).to receive(:shell_out!)
- expect(provider).to_not receive(:shell_out!)
- .with("#{systemctl_path} --user daemon-reload", **user_cmd_opts, default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to_not receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "daemon-reload", **user_cmd_opts, default_env: false)
provider.action_delete
end
@@ -352,16 +351,16 @@ describe Chef::Provider::SystemdUnit do
it "presets the unit" do
new_resource.user("joe")
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user preset #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "preset", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_preset
end
it "reverts the unit" do
new_resource.user("joe")
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user revert #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "revert", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_revert
end
@@ -371,9 +370,9 @@ describe Chef::Provider::SystemdUnit do
it "triggers a daemon-reload when creating a unit with triggers_reload" do
allow(provider).to receive(:manage_unit_file).with(:create)
expect(new_resource.triggers_reload).to eq true
- allow(provider).to receive(:shell_out!)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system daemon-reload", default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_create
end
@@ -383,18 +382,18 @@ describe Chef::Provider::SystemdUnit do
.and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
expect(new_resource.triggers_reload).to eq true
- allow(provider).to receive(:shell_out!)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system daemon-reload", default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_delete
end
it "does not trigger a daemon-reload when creating a unit without triggers_reload" do
new_resource.triggers_reload(false)
allow(provider).to receive(:manage_unit_file).with(:create)
- allow(provider).to receive(:shell_out!)
- expect(provider).to_not receive(:shell_out!)
- .with("#{systemctl_path} --system daemon-reload", default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to_not receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_create
end
@@ -404,9 +403,9 @@ describe Chef::Provider::SystemdUnit do
.with(unit_path_system)
.and_return(true)
allow(provider).to receive(:manage_unit_file).with(:delete)
- allow(provider).to receive(:shell_out!)
- expect(provider).to_not receive(:shell_out!)
- .with("#{systemctl_path} --system daemon-reload", default_env: false)
+ allow(provider).to receive(:shell_out_compacted!)
+ expect(provider).to_not receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "daemon-reload", default_env: false)
provider.action_delete
end
it "deletes the file when it exists" do
@@ -431,15 +430,15 @@ describe Chef::Provider::SystemdUnit do
end
it "presets the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system preset #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "preset", unit_name)
.and_return(shell_out_success)
provider.action_preset
end
it "reverts the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system revert #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "revert", unit_name)
.and_return(shell_out_success)
provider.action_revert
end
@@ -450,8 +449,8 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "reenables the unit" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user reenable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "reenable", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_reenable
end
@@ -459,8 +458,8 @@ describe Chef::Provider::SystemdUnit do
it "enables the unit when it is disabled" do
current_resource.user(user_name)
current_resource.enabled(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user enable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "enable", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_enable
end
@@ -468,22 +467,22 @@ describe Chef::Provider::SystemdUnit do
it "does not enable the unit when it is enabled" do
current_resource.user(user_name)
current_resource.enabled(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_enable
end
it "does not enable the unit when it is static" do
current_resource.user(user_name)
current_resource.static(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_enable
end
it "disables the unit when it is enabled" do
current_resource.user(user_name)
current_resource.enabled(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user disable #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "disable", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_disable
end
@@ -491,64 +490,64 @@ describe Chef::Provider::SystemdUnit do
it "does not disable the unit when it is disabled" do
current_resource.user(user_name)
current_resource.enabled(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_disable
end
it "does not disable the unit when it is static" do
current_resource.user(user_name)
current_resource.static(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_disable
end
end
context "when no user is specified" do
it "reenables the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system reenable #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "reenable", unit_name)
.and_return(shell_out_success)
provider.action_reenable
end
it "enables the unit when it is disabled" do
current_resource.enabled(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system enable #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "enable", unit_name)
.and_return(shell_out_success)
provider.action_enable
end
it "does not enable the unit when it is enabled" do
current_resource.enabled(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_enable
end
it "does not enable the unit when it is static" do
current_resource.static(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_enable
end
it "disables the unit when it is enabled" do
current_resource.enabled(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system disable #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "disable", unit_name)
.and_return(shell_out_success)
provider.action_disable
end
it "does not disable the unit when it is disabled" do
current_resource.enabled(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_disable
end
it "does not disable the unit when it is static" do
current_resource.user(user_name)
current_resource.static(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_disable
end
end
@@ -559,8 +558,8 @@ describe Chef::Provider::SystemdUnit do
it "masks the unit when it is unmasked" do
current_resource.user(user_name)
current_resource.masked(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user mask #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "mask", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_mask
end
@@ -568,15 +567,15 @@ describe Chef::Provider::SystemdUnit do
it "does not mask the unit when it is masked" do
current_resource.user(user_name)
current_resource.masked(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_mask
end
it "unmasks the unit when it is masked" do
current_resource.user(user_name)
current_resource.masked(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user unmask #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "unmask", unit_name, **user_cmd_opts)
.and_return(shell_out_success)
provider.action_unmask
end
@@ -584,7 +583,7 @@ describe Chef::Provider::SystemdUnit do
it "does not unmask the unit when it is unmasked" do
current_resource.user(user_name)
current_resource.masked(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_unmask
end
end
@@ -592,29 +591,29 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "masks the unit when it is unmasked" do
current_resource.masked(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system mask #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "mask", unit_name)
.and_return(shell_out_success)
provider.action_mask
end
it "does not mask the unit when it is masked" do
current_resource.masked(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_mask
end
it "unmasks the unit when it is masked" do
current_resource.masked(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system unmask #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "unmask", unit_name)
.and_return(shell_out_success)
provider.action_unmask
end
it "does not unmask the unit when it is unmasked" do
current_resource.masked(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_unmask
end
end
@@ -625,8 +624,8 @@ describe Chef::Provider::SystemdUnit do
it "starts the unit when it is inactive" do
current_resource.user(user_name)
current_resource.active(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user start #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "start", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_start
end
@@ -634,15 +633,15 @@ describe Chef::Provider::SystemdUnit do
it "does not start the unit when it is active" do
current_resource.user(user_name)
current_resource.active(true)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_start
end
it "stops the unit when it is active" do
current_resource.user(user_name)
current_resource.active(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user stop #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "stop", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_stop
end
@@ -650,7 +649,7 @@ describe Chef::Provider::SystemdUnit do
it "does not stop the unit when it is inactive" do
current_resource.user(user_name)
current_resource.active(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_stop
end
end
@@ -658,29 +657,29 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "starts the unit when it is inactive" do
current_resource.active(false)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system start #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "start", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_start
end
it "does not start the unit when it is active" do
current_resource.active(true)
- expect(provider).to_not receive(:shell_out!)
+ expect(provider).to_not receive(:shell_out_compacted!)
provider.action_start
end
it "stops the unit when it is active" do
current_resource.active(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system stop #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "stop", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_stop
end
it "does not stop the unit when it is inactive" do
current_resource.active(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_stop
end
end
@@ -690,8 +689,8 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "restarts the unit" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "restart", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_restart
end
@@ -699,8 +698,8 @@ describe Chef::Provider::SystemdUnit do
it "reloads the unit if active" do
current_resource.user(user_name)
current_resource.active(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user reload #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "reload", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_reload
end
@@ -708,30 +707,30 @@ describe Chef::Provider::SystemdUnit do
it "does not reload if the unit is inactive" do
current_resource.user(user_name)
current_resource.active(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_reload
end
end
context "when no user is specified" do
it "restarts the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system restart #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "restart", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_restart
end
it "reloads the unit if active" do
current_resource.active(true)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system reload #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "reload", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_reload
end
it "does not reload the unit if inactive" do
current_resource.active(false)
- expect(provider).not_to receive(:shell_out!)
+ expect(provider).not_to receive(:shell_out_compacted!)
provider.action_reload
end
end
@@ -741,8 +740,8 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "try-restarts the unit" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user try-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "try-restart", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_try_restart
end
@@ -750,8 +749,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "try-restarts the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system try-restart #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "try-restart", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_try_restart
end
@@ -762,8 +761,8 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "reload-or-restarts the unit" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user reload-or-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "reload-or-restart", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_reload_or_restart
end
@@ -771,8 +770,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "reload-or-restarts the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system reload-or-restart #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "reload-or-restart", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_reload_or_restart
end
@@ -783,8 +782,8 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "reload-or-try-restarts the unit" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --user reload-or-try-restart #{unit_name_escaped}", **user_cmd_opts, default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--user", "reload-or-try-restart", unit_name, **user_cmd_opts, default_env: false)
.and_return(shell_out_success)
provider.action_reload_or_try_restart
end
@@ -792,8 +791,8 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "reload-or-try-restarts the unit" do
- expect(provider).to receive(:shell_out!)
- .with("#{systemctl_path} --system reload-or-try-restart #{unit_name_escaped}", default_env: false)
+ expect(provider).to receive(:shell_out_compacted!)
+ .with(systemctl_path, "--system", "reload-or-try-restart", unit_name, default_env: false)
.and_return(shell_out_success)
provider.action_reload_or_try_restart
end
@@ -809,16 +808,16 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "returns true when unit is active" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-active #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
.and_return(shell_out_success)
expect(provider.active?).to be true
end
it "returns false when unit is inactive" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-active #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-active", unit_name, user_cmd_opts)
.and_return(shell_out_failure)
expect(provider.active?).to be false
end
@@ -826,15 +825,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when unit is active" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-active #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-active", unit_name)
.and_return(shell_out_success)
expect(provider.active?).to be true
end
it "returns false when unit is not active" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-active #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-active", unit_name)
.and_return(shell_out_failure)
expect(provider.active?).to be false
end
@@ -850,16 +849,16 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "returns true when unit is enabled" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-enabled #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
.and_return(shell_out_success)
expect(provider.enabled?).to be true
end
it "returns false when unit is not enabled" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-enabled #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
.and_return(shell_out_failure)
expect(provider.enabled?).to be false
end
@@ -867,15 +866,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when unit is enabled" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-enabled #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
.and_return(shell_out_success)
expect(provider.enabled?).to be true
end
it "returns false when unit is not enabled" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-enabled #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
.and_return(shell_out_failure)
expect(provider.enabled?).to be false
end
@@ -891,16 +890,16 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "returns true when the unit is masked" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user status #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
.and_return(shell_out_masked)
expect(provider.masked?).to be true
end
it "returns false when the unit is not masked" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user status #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "status", unit_name, user_cmd_opts)
.and_return(shell_out_static)
expect(provider.masked?).to be false
end
@@ -908,15 +907,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when the unit is masked" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system status #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "status", unit_name)
.and_return(shell_out_masked)
expect(provider.masked?).to be true
end
it "returns false when the unit is not masked" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system status #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "status", unit_name)
.and_return(shell_out_static)
expect(provider.masked?).to be false
end
@@ -932,16 +931,16 @@ describe Chef::Provider::SystemdUnit do
context "when a user is specified" do
it "returns true when the unit is static" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-enabled #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
.and_return(shell_out_static)
expect(provider.static?).to be true
end
it "returns false when the unit is not static" do
current_resource.user(user_name)
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --user is-enabled #{unit_name_escaped}", user_cmd_opts)
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--user", "is-enabled", unit_name, user_cmd_opts)
.and_return(shell_out_masked)
expect(provider.static?).to be false
end
@@ -949,15 +948,15 @@ describe Chef::Provider::SystemdUnit do
context "when no user is specified" do
it "returns true when the unit is static" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-enabled #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
.and_return(shell_out_static)
expect(provider.static?).to be true
end
it "returns false when the unit is not static" do
- expect(provider).to receive(:shell_out)
- .with("#{systemctl_path} --system is-enabled #{unit_name_escaped}", {})
+ expect(provider).to receive(:shell_out_compacted)
+ .with(systemctl_path, "--system", "is-enabled", unit_name)
.and_return(shell_out_masked)
expect(provider.static?).to be false
end