From d8b3f05774613c949c8ed33a48122a27b2cd053a Mon Sep 17 00:00:00 2001 From: Nathan Williams Date: Fri, 6 May 2016 14:37:46 -0700 Subject: add more unit actions --- spec/unit/provider/systemd_unit_spec.rb | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'spec') diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb index e71885f32d..a76f9e433a 100644 --- a/spec/unit/provider/systemd_unit_spec.rb +++ b/spec/unit/provider/systemd_unit_spec.rb @@ -629,6 +629,69 @@ describe Chef::Provider::SystemdUnit do end end + describe "try-restarts the unit" 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_systems_locale!) + .with("#{systemctl_path} --user try-restart #{unit_name}", user_cmd_opts) + .and_return(shell_out_success) + provider.action_try_restart + end + end + + context "when no user is specified" do + it "try-restarts the unit" do + expect(provider).to receive(:shell_out_with_systems_locale!) + .with("#{systemctl_path} --system try-restart #{unit_name}", {}) + .and_return(shell_out_success) + provider.action_try_restart + end + end + end + + describe "reload-or-restarts the unit" 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_systems_locale!) + .with("#{systemctl_path} --user reload-or-restart #{unit_name}", user_cmd_opts) + .and_return(shell_out_success) + provider.action_reload_or_restart + end + end + + context "when no user is specified" do + it "reload-or-restarts the unit" do + expect(provider).to receive(:shell_out_with_systems_locale!) + .with("#{systemctl_path} --system reload-or-restart #{unit_name}", {}) + .and_return(shell_out_success) + provider.action_reload_or_restart + end + end + end + + describe "reload-or-try-restarts the unit" 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_systems_locale!) + .with("#{systemctl_path} --user reload-or-try-restart #{unit_name}", user_cmd_opts) + .and_return(shell_out_success) + provider.action_reload_or_try_restart + end + end + + context "when no user is specified" do + it "reload-or-try-restarts the unit" do + expect(provider).to receive(:shell_out_with_systems_locale!) + .with("#{systemctl_path} --system reload-or-try-restart #{unit_name}", {}) + .and_return(shell_out_success) + provider.action_reload_or_try_restart + end + end + end + describe "#active?" do before(:each) do provider.current_resource = current_resource -- cgit v1.2.1